Pugs are generally rather intelligent, and even though they can sometimes be a bit stubborn, they are usually quite easy to train. But they can be difficult to housebreak. This is a common tendency with small companion dogs and it is nothing that a bit of patience and resolve on your part cannot solve.
Each time it goes outside repeat a predetermined phrase. That way if you take him out and he is just playing around you can say the phrase and he’ll realize that he is taken out with a purpose. You’ll need to spend as much time with him as you can, this way you’ll be able to prevent him from having accidents in the house. If you see him starting to evacuate in the house quickly pick him up, while scolding him in a low voice and take him outside. If he keeps evacuating when he is out praise him and offer a reward. In time, you’ll learn to recognize the signs that your dog sends when he needs to go to the bathroom and you’ll be able to take him out in time.
You might also want to help him with sending the signals. Some people install a little bell next to the door. Each time that they are taking the dog out they ring the bell. After a while the dog learns to connect the sound of the bell with going outside and will alert you of his need by ringing it himself. Of course, other people find the sound rather annoying and quickly give up on this system.
If you realize that he dog has had an accident inside but you didn’t catch him in the act, don’t bring him to the scene of the crime and punish him. This will only confuse him into thinking that you generally disapprove of him going to the potty and will hide from you next time he needs to go. Punish him only in you catch him while he is doing it.
This process might take a while and it will definitely be full of frustration and disappointments, but if you are patient enough it will result in a perfectly house trained puppy that will never again have an accident inside the house.