Mary Reed Newland has a very good book that addresses this topic in one of it's chapters. I believe it's called "How to Raise Good Catholic Children".
Basically the premise is to start young--about 2 or so--in teaching them purity and modesty. Little children start exploring their personal areas at that age, due to potty training. I always tell them to say, "Jesus, help me be pure".
When they get older, about 5 or so, and I notice an upsurge in it again, we have a little chat about using our body parts respectfully, as God intended. Then I tell them if they want to do something like that, come to me right away and we'll say a Hail Mary together. I check in periodically with them--timing varies depending on the child--to see if they're still having trouble with purity.
Both my husband and I are available to them if they have any questions about the reproduction issue as they get older. I tell my boys if they're having impure thoughts to say mentally, "I reject this thought" or "St Joseph, Protector of Virgins, defend me", and then to start saying the mulitiplication tables, play mental alphabet games, etc for distraction. If they still have trouble, they can come to either one of us and say, "I'm having trouble"; our code for impure thoughts/impulses so the siblings won't key in to what's going on, and I will come with them and we'll say some prayers in front of the crucifix (in their room or quiet area).
Also, Bishop Zendejas said that if you give up meat on Wednesday in honor of St. Joseph, he will help maintain purity. So all my adolescents have voluntarily done so.
I think the key is to be charitable and kind, and not act embarrased. If they come to you with this problem, being upset and harsh is the worst thing you can do. You think they'll come back after you've yelled at them? Or physically punished them? Imposing some sort of discipline, say push-ups for boys, or washing the floor on their hand and knees for girls, is appropriate but I am never harsh or angry about it. I want my children to come to me with their problems, not be afraid. It's worked so far.