It's a very strange thing to ask somebody who's serving you in a shop. It's very nosey and, as a white person, I think it's passive racism.
If somebody works in a shop, they're almost certainly from the same town/area or a nearby one.
As PP have said, if you have a clearly foreign accent, it's obvious that you aren't originally from this country. If they were a regular customer and you struck up a rapport with them over time, it's the kind of question they might ask, along with do you have any kids? Did you see xxx on the telly last night? etc. As a general rule, if it's their first question and/or asked before they've actually greeted you or asked your name (if it isn't on a badge - and told you theirs), then it's racially motivated.
The main determiner would surely be what their response is to the information once you've answered their question. If it's to comment "I thought you might be Jamaican! We have friends out there we visit a lot; I wish we were there now!" then it's still very misguided, but probably intended to come from a good place.
if their response is to cast doubt on your answer or just reply with a dismissive "Oh", then it is racially motivated. It's in the same category of prejudice as asking a female plumber how long she's been in the job when the same person wouldn't dream of asking the same question of your male colleague (unless, say, she looks 15 and he's in his 40s).
It's shorthand for saying "I have misgivings about you because you look 'different' - you need to justify yourself and satisfy me of your abilities or intentions in order to gain my acceptance".
I would advise him to answer their question with a question and force them to confront their prejudice (or at least show themselves up - make them squirm):
"Where are you from?"
"I do work here, Sir/Madam - how can I help you?"
"Yes, but where are you from?"
"Why do you ask?"
"I just wondered."
"What made you wonder - does it matter?"
"Erm, well, you look, um, different."
"Do I? Have I changed since you were in here last?"
"No, I mean.... your skin is a different colour."
"No, it's always been this colour."
"Noooo - you're not white."
"Oooooh, I've noticed that as well!! Is that relevant? Did you want serving? Sorry, we're quite busy here."
"Yes, of course - I just didn't know if you'd be able to help me."
"Why? Because of my colour?"
"Errrrrmmmmmm........."
These people need calling out, even if only for their own good, as consciously or subconsciously, it's racism. Just because they aren't shouting it at you as abuse, it's still totally unacceptable.