Attention defines a relationship. Without it, there is not much interaction. Young puppies usually stay close to their people, and pay a lot of attention to them, but as they get older they start to explore more of the world. Dogs find that exploration reinforcing, and pay less attention to their people. If your goal is for your dog to respond to his name by looking at you— in any situation—then you have to train and practice that skill. Playing the "Name Game" (saying your dog's name and clicking and treating when he looks at you) is the most basic form of training attention.
If you follow through with this exercise, you establish a solid response to calling your dog's name. Start inside at a low level of distraction and at close distance. Then, work in more distracting environments gradually, to get a solid response in many different situations. If your dog does not respond in a particular environment, make it easier. Find a less distracting place or moment, and try again. Your job is to assess the training environment and VERY GRADUALLY increase the level of distraction. Make sure your reinforcement (treats or play) is of high value—let your dog tell you what he wants.
When your dog offers attention, be prepared to reinforce that attention. For example, when I am out on a walk with young Deagan, my Large Munsterlander, and he looks at me, I respond to him. (Note that there are other times when I ask for his attention when he is not looking at me.) I may praise him, or click/treat, or give him a cue to do a simple behavior (cues taught with positive reinforcement are themselves reinforcing). His attention to me in a distracting environment is always reinforced in some way. Communication goes both ways, so it is important to recognize when your dog is performing the behavior well.
Every walk is an opportunity for training because the environment is always presenting new distractions. Your dog is always learning. Good luck playing "the Name Game"—and have fun!