Provide control for the child. If not, provide physical control. Sometimes a simple touch will do it. Other times you need firm physical control, even to the point of removing the child from the situation. Prevent the behavior from happening.
Prevention is even more effective than prohibiting.
Family day care providers get very good at predicting what is going to happen. Teach a desired behavior through modeling. If you are trying to teach a child to be gentle to your dog, you can't jerk him away from the dog and yell at him. Those are the very behaviors you are trying to eliminate. You need to show him how to gently pet your dog.