I do this too, dog is free to sniff and walk wherever as long as she doesn't pull on the leash...for that I use a slow down command if/when she pulls. If I want a heel, I use that command, then no sniffing and no getting out of the proper position for heel.
I will say that what makes this difficult is that you walk your dog all the time, and if you're like me, you just want the ***** Dog to get with the program so the walk is enjoyable LOL! IME it can't be accomplished that way...or at least not very quickly. To actually train these behaviors you have to forget any agenda and consider your walks a training session - i.e. no set distance or specific time frame. It's not an exercise routine, it's training until the dog gets it. I always stop for a full 2-3 minutes every time the dog is not getting it right, no additional commands, nothing verbal period. Dog doesn't heel correctly, stop, calmly move the dog back into position, then stand still for another couple minutes before starting on. It is effective!
It's not the size of the dog in the fight, it's the size of the fight in the dog. Mark Twain