If you can neuter/spay an animal before it's hormones kick in, then you can usually avoid marking. Unfortunately once it's a learned behavoir it's much more tricky to stop it. Does he do it in front of you or while you are away? You may want to consider crating until you can get it under control.