When your dog makes a habit of running away, you need to establish a sense of order and discipline. Remember that discipline and punishment are not the same thing, and if you punish your dog for running away, you're only going to make him want to do it again. After all, when he comes close, he gets punished! Discipline is about training and establishing rules. Once you do that, he'll stop taking off every chance he gets.
Exercise your dog before disciplining. A long walk helps him burn off the extra energy, and it helps remind him that you're the boss. Give him commands throughout the walk and make sure that he isn't doing things like tugging on the leash -- all of this reinforces your dominance in the relationship.
Keep your dog in an area from which he cannot run away. For example, train him in a fenced-in backyard from which he can't escape. You can't hope to discipline your dog in a wide-open space, in which he'll be tempted to run. If you don't have a closed-in area to train in, stay in a familiar area like your yard and simply keep him on a long leash.
Teach him the "come" command. If he doesn't know this word, reinforce its meaning by saying it in a high-pitched, excited and happy voice. Every time he comes, shower your dog with praise. You can even reward him with a small treat. This type of positive reinforcement training teaches your dog that coming when he's called is a good thing, and that he'll be rewarded for it. If your dog detects anger or stress in your voice when you give the command, or if you punish him when he comes after running away, he'll learn to ignore the command.
Practice the "come" command in different environments, including ones with increasingly more distractions, like the beach or the dog park. Remember to always praise him when he comes. This may not sound like discipline in the traditional sense, but what it does is give your dog a sense of consistency, order and submission. He learns to listen to you and do what you tell him, including coming back when he starts to wander off.