I know, it can be an embarrassing issue, especially when your dog is getting his groove on when the company is over!
According to an article on the The Pet Place Web Site, humping is not only considered a sexual action, it can also mean other things. In fact, it can be a signal of power and rank.
Essentially, some dogs hump as a way of asserting themselves. Whatever the motivation, when humping is directed toward peoples' legs, or objects in the environment, the result is the same: embarrassment for the dog owner and any guests who happen to be present.
Check out the article...