Be proactive and teach your dog what you want them to do rather than waiting for them to make the wrong choice. Instead of waiting for them to jump on someone and then telling them "Off", teach them the polite way to greet people.
Always check in with your dog before letting someone pet them. Even the most friendly dog can have a bad day or get a bad vibe from someone and not want to be petted. Forcing them can set them up to make a costly mistake. Forced petting does not help shy dogs like strangers!
Getting behind you, crouching down, flattened ears, wide eyes, and growling are all signs that your dog does not want to be petted by this person. Tell them your dog is in training, having a bad day, sick, whatever you choose but the answer is no. Your dog is not the world's petting zoo, and it is OK to say NO, you may not pet my dog.