He should not have been allowed free, unsupervised access to the home at the beginning. Pens and crates are wonderful training tools for dogs of any age. You can begin over and housetrain the dog now. Here is the method I use.
Schedule-Confine-Supervise
Schedule- the feeding and potty times. An adult is fed twice a day. A puppy is fed four times a day up to 10 or 12 weeks, then three times a day through adolescence. They need to potty first thing in the morning, last thing at night, within a few minutes of every meal, and every few hours in between. The “in between” hours are calculated by their age in months: 1 month = 1 hour, up to 6 months/hours. So, a three month old puppy should be taken to potty every three hours in between the other scheduled times. When the dog/puppy is taken to potty, wait with him as he ‘does his business’ and then praise like crazy. The neighbors should be able to hear you.
Confine- the puppy or dog whenever it is not being watched. Confinement can be in a crate (especially at night), an exercise pen, or behind a baby gate in a very small and puppy-proofed room.
Supervise- the puppy or dog whenever it is loose in the home. This means having eyes on it, not on the TV. Play with the puppy, do a five minute training session, groom it, or just let it lie at your feet with a safe chew, but have it within sight at all times. If it squats then give a loud “NO” or “ACK” as you scoop and run to the appropriate potty spot.
Do not let the dog return to the accident spot until it has been thoroughly cleaned and wiped with vinegar or a commercial enzyme product to remove all urine odor.