Assuming you're parents that see your young son doing something you don't like, and you want to avoid him to do it. What's of these following ways more natural?
Don't do it!
Don't do that!
They are essentially interchangeable.
Corpus data from parental spoken language is so rare, it would be difficult to establish which is more frequent or idiomatic.
Based on the discourse function of "that", don't do that! sounds a bit more like a reproach after a child has done something bad ("that" thing), e.g. after the child already pulled someone's hair.
Don't do it! could be more of a warning as the child is ready to do something bad ("it"). This is not a precise distinction, though, and they are interchangeable.