Stealth Rock is an egg move for Foretress, so you'll have to breed Foretress with any Pokemon in the Bug group. But only the male passes down moves. So if you get a male Pokemon that knows Stealth Rock that is in the bug egg group, and you get a female Foretess, the egg will be a Pineco.
Example:
So, Gliscor can learn Stealth Rock as a TM in HG/SS/Platium.
Breed a male Gliscor (that knows Stealth Rock) with a female Pineco/Foretress, and the baby will be a Pineco with the move Stealth Rock.
This is just one example, there are more Pokemon that can apply to this as well.
Hope This Helped :D