The ASPCA (American Society for the Prevention of Cruelty to Animals) suggests:

Never allow a child to approach a dog that is sleeping, eating, taking care of puppies or chewing a toy or bone.

Never allow a child to approach a dog that is barking, growling or seems afraid.Teach your child to ask permission to pet an unfamiliar dog. If the owner says it's OK, your child should allow the dog to sniff a closed hand, then gently pet it on the shoulders or chest instead of the top of the head.Explain to your child to never approach a loose dog. A child also should never try to pet a dog behind a fence or inside a car.