Teaching a puppy to use the bathroom outside is one of the first most time consuming tasks of puppy training. At its most basic level it boils down to this: dogs will 'go' on a surface that is familiar to them. When our dog Paisley first arrived from a southern Arizona ranch, she wouldn't relieve herself--even after a long plane ride--until we finally walked her off the grass and over to some rocks.
It is likely that a dog that has never, ever peed on carpet or wood floors is not likely to ever have an 'accident' on carpet or wood floors. With house training prevention is really everything!
Having said that, every puppy will have an accident or two--we are talking about babies after all! If the pup is punished by the owner for eliminating in his presence, then the pup will often learn that peeing in the owner's presence is the problem and will learn go out of sight to eliminate (that often means behind the couch, in the closet etc.). Patience, praise, diligence and high value food rewards are the keys to successful house training. That means that for a while you have to go outside with your puppy and watch until he pees and poops. Rewarding the eliminating outside is what will make the behavior intentional.
Here are some favorite articles: