Ditto on the neuter and vet. After that, Buy a new mattress and keep him out of the room when he's unsupervised. The reason I say buy a new mattress is your post sounds as if he's marked the one you have but good, it's become a habit, and he's always going to smell where he's been. And we all know about the beagle nose.