Not exactly sure where OP was...sounds like it was in a pet store but there are just some places where I don't expect people to leave me alone. Especially if I have a GSD puppy with me. If I'm at a pet store...even if I look like I'm working on things, I expect that people will ask to pet my dog. If I'm standing in line and someone bends down to pet my dog, I usually don't gripe about it. A dog shouldn't be out in public (especially a store) where it will be in close quarters with a bunch of people if its not safe to be pet.
Now...if I'm at a park, in the middle of a large field, clearly working, I expect that people won't go out of their way to pet my dog. And this is something that has never happened to me, especially since my puppy turned into a fully grown GSD. I also tend not to work my dog for long periods of time at stores. I will heel for a few aisles, work on some sits/downs, but it really doesn't last more than a few minutes. If someone comes up to say hello, I'll allow them to, there are dog lovers at a pet store and they can't resist a beautiful/well behaved dog. When he was younger and did have jumping tendencies, I would just correct any over excitement.
I know we run into plenty of people that don't ask to pet our dogs, but I definitely meet more that do than don't.