Be persistent! Make sure the puppy doesn't get the opportunity to pee and poop by using a leash indoors or confining him to a crate when you're out. Depending on the puppies age, pop him outside every 20 - 30 minutes, so there's a greater chance of him toileting outside (by accident at first.) In addition, get rid of any scent markers he's left by peeing or pooping indoors, as these will draw him back to the same spot. This means cleaning the area daily, for 2- 3 weeks after he last pooped there to fully get rid of any lingering odor that the dog can detect.
Positive reinforcement is the key to success. A common mistake is to punish your dog during training or become angry. This will only cause confusion. You can try to hold your dog's attention with treats and enthusiasm, but know that it is time to end a session when your dog becomes bored or tired. Try to end sessions on a positive note. Eventually, successful training will be achieved with patience and consistency.
It’s best not to punish the puppy for making a mistake. Instead, focus on praising appropriate bathroom behavior. If you catch your puppy in the act, interrupt it by saying “No!” in a firm voice or clapping your hands loudly, then take the puppy outside to finish going to the bathroom. Never swat your puppy, yell at it, or try to rub its nose in the mess.