Dogs and cats sniff bums because the anal glands hold a lot of information, such as age, sex, point in reproduction cycle, level in pack dominance, and much more. It makes sense that animals would do this upon meeting each other, and even after knowing each other for a long time. Think of it as an animal's way of saying "How was your day? How are you feeling?" It's also an animal's way of asserting or allowing dominance. (Interesting point: when an animal lifts their bums when they get scratched, they're inviting you to sniff it!)
Obviously humans don't sniff each others bums. Our sense of smell is no where near what a dogs sense of smell is, so we don't understand why an animal might do this and an animal doesn't understand why we might find this embarrassing.
It's important that when your dog does this, you don't just distract him, unless you plan to have every visitor in your house do this. That will also train him that when he tries to sniff a humans bum, he will be rewarded. If you go that direction and then do something different when he does it to someone else, it will be extremely confusing.
Animals work by instant association. If I do this, this will happen. You need to teach him that if he tries to sniff a human in an undesirable area, something will happen. You don't need to do anything that will cause pain (and please don't), so think of something a fellow puppy or mother dog would do. If I had a dog that continued this, I would gently push his nose away, then walk away. No loud noises or sharp movements, or he'll start to associate you coming home and taking shoes and coats off with that. Act completely normal otherwise, just gently push his nose away so he's facing away from you, then act normal again. Eventually he'll make the association that doing that will cause his nose to be pushed away, much like how a fellow dog would nudge him away when he's doing something wrong, and he'll stop. Ensure that if he's doing it to company, you do the same thing. If you can tell the person before they come over the process, do. Otherwise, don't waste time telling them or the period of association will be over.