Teaching your dog to come when you call him is arguably the most important bit of training you can do with him. If your pup knows just one command, this should be it. A dog who can be reliably recalled can be free to run off the lead in parks or on hikes, presuming that's allowed and not unsafe, with you secure in the knowledge that he will come back when you need him to.
Determine Your Command
When teaching your dog to come, you need to decide on a recall command. Some people just use their dog's name; others prefer to use the command "come." Some use name and command together: The name to get the dog's attention, and the command to direct him.
Start in a Secure Environment
Start your training either inside or in an enclosed yard. Your dog should be loose and somewhere fairly close by. Use your recall command and encourage your dog toward you by standing in an open and inviting posture, and patting your hand on your thigh. When he comes over, immediately praise him and give a treat.
Positive Reinforcement
Don't underestimate the power of positive reinforcement. You dog needs to learn that coming back to you is a good thing that results in something pleasurable for him. Start off using extremely high-value treats -- those he loves but doesn't often get -- so that coming to you when you call is worth his while. Once he starts getting the hang of things, stop giving a food treat every time. Instead, alternate between treats, verbal praise, physical attention such as strokes and pats, and short play sessions.
Trial and Error
It can take a bit of trial and error when learning recall. Call your dog just once, or twice at most. If he won't come to you, go over to him, take him gently by the collar and lead him to where you were calling from, then let him go and try again. As soon as he starts coming toward you after you issue the recall command, begin cheering him on or praising him verbally, so he's on the right track, and reward him once he reaches you.
What Not to Do
Never punish your dog for not coming right away. If you can, go to him and get him yourself. If he's out of sight or otherwise inaccessible, wait for him to come back. No matter how annoyed you are, praise him once he eventually returns. If you scold him for running off once he gets to you, he'll think you're scolding him for coming back. Don't panic. Remember that no dogs are perfect; even those with great recall loyalty might suffer the odd lapse.
One More Thought
If your pup's heading toward a dangerous situation, try calling while running away from him rather than toward him. If you run after your dog, he's likely to run away faster -- but hightail it in the other direction and he'll probably run after you.