I believe its more of a dominance thing than a sexual thing when dogs do that, Ive seen dogs do it to objects, other dogs and people, So you musnt worry or be embarrased, But you need to show your dog you are the dominant one (or the leader of the pack) of the household not him.
Always make him sit (say please) before you give him any attention
Always go through a doorway first make him wait for you.
When he is doing it making him stop dont encourage it, but dont punish him either, just divert his attention to something else, Ignore the behaviour