Was his urine rechecked to ensure that the infection is gone? And did your vet suggest you switch foods? Medical causes should always be ruled out first (I'm glad you phrased your question like that

). That said, I would treat him like an untrained puppy for the time being - he should always be on-lead when not in his crate, take him out regularly, praise for going outside. If it's a medical problem, this should help avoid accidents, and if it's a behaviour problem, it's what you'd need to be doing anyway (i.e. a refresher course in housebreaking).