Taking them to the Vet. should be the 1st thing to do when something like this starts.
I have 4 cats now and have had cats for the last 2o years and never had one urinate in the house, can't say that for the 5 small dogs I've had.
If a dog spends too much time outside, they seem to get mixed up as to where they should go potty. I try to keep mine inside and let them out every so often to potty, this works out well for mine.