Remove him from the situation: If your dog continues to hump someone, remove him from the situation and put him in a time-out. This will show him that humping is not acceptable and will help him to calm down.
Squirting water at him: Squirting water at your dog may be an effective way to deter him from humping. However, it is important to use this method only as a last resort, and only if your dog is not responding to other methods. Avoid squirting water in your dog's face, as this can be harmful to his eyes. Instead, squirt water at his stomach or hindquarters.
Neuter your dog: If your dog is not neutered, neutering him may help to reduce his humping behavior. Neutering removes the testicles, which are the source of testosterone, a hormone that can contribute to humping behavior.
Consult a trainer: If you are having difficulty stopping your dog from humping, consult a professional dog trainer. A trainer can help you to develop a training plan that is specific to your dog's individual needs.