Spook is correct in that you can use a Heart Scale to "remind" a Forretress how to use Toxic Spikes. However, it is also possible to breed for it, removing the need for the Heart Scale, if you were so inclined. It will require 2 breeding steps in this instance, one for Toxic Spikes, and one for Stealth Rock.
To do this will require a Male Scorupi/Drapion or Beedrill that knows Toxic Spikes. Breed it with a Female Pineco/Forretress to get one that knows Toxic Spikes. You will again want a Female, so that you can breed in Stealth Rock from the Dweeble/Crustle.
In the interest of "protecting" the move, it is recommended that you open the Summary page of the Female Toxic Spikes Pineco, and sort Toxic Spikes to the bottom slot. This ensures that that move will be the last one the game attempts to accommodate when determining Egg Moves for offspring.
Now that you have your Female Toxic Spikes Pineco, you will need a Male Dweeble/Crustle that knows Stealth Rock. Put the 2 together, and hatch your Pineco with Toxic Spikes and Stealth Rock. If you are going to breed in any other moves, you should again keep hatching until you get a Female. But otherwise, you'd be done here.
Note that you can do this process in either order. As long as you sort the desired move to the bottom of the Pokemon's Summary page, it will work both ways.