Crate training should help. It uses the dog's natural instincts to not soil in their "den".

I'd also take him to the vet to have him cleared of any medical problems that may be causing him to not be able to hold it in.