First choose a toilet spot for your dog outside. If your dog has an accident inside, clean it up and take the poop and if urine paper toweling outside and put in your toilet spot. Leave it for 2 days, sometimes giving it a hose down will help trap the smell into the ground. Dogs are attracted to their smell, so try to get the smell where he should be going.
If your dog has an accident inside, the best way to clean it is to clean the area with an enzymatic, low-perfume laundry detergent such as Bio Zet or a product specifically designed for this purpose such as X-Tract. This product contains natural enzymes to break down the waste residue.
Next close the doors to target rooms and if necessary cover the rugs or carpets with black plastic or a painter's plastic drop sheet until the problem is fully resolved.
the last step is to re-toilet train your dog, Your dog is more likely to need to soil after eating, drinking, sleeping or exercising and of course, when it hasn't 'done one' for a while. When home take the pup to your toilet area every hour & after waking or eating and if your dog does something, say the cue words "Go Potty", make a big fuss and give your dog a really nice treat, cheese and small pieces of sausage are good. You have to teach your dog that doing something in front of you is a big reward situation, so it is important not to punish mistakes inside, or he will stop going if your around. Once he starts to catch on you can slowly increase the length of time before going outside, but expect some accidents for a while.
It would be a good idea to restrict his movements when you are not there, so a crate is a good idea. It takes time and commitment to train a pup, keep your eye on him at all times and if you can't then you crate him.