I can tell you now you are about to get answers like push him away and say NO.... I can also tell you it NEVER worked with mine lol he even chased down a squirrel to pen and hump.

he finally stopped after he was neutered and has not done it since soooo with that being said try the other options people give then if that does not work you might end up having to go the route I went.