Your question leaves off the rest of it.
What if you won an award or got a medal - would you be complaining if they said, "You must have done something to deserve...?"
If it's a negative (as the prior answers imply), then I'd say you might best chalk it up to bad manners and thoughtlessness.
As such, you can either politely explain that they're mistaken or you might try confusing them.
Here's an example:
Person A: You must have done something to deserve a fine. What'd you do?
Person B: Thank you so much for your concern.
Person A: Yeah, okay. But what'd you do? How much was the fine, anyway?
Person B: Really? Okay, I'll take that under consideration.
As you can see, the answer you give has nothing to do with their question - which ultimately confuses them and may make them stop asking.
If they continue asking questions, you can try simply saying "Thanks for asking." Sometimes, they'll automatically say "You're welcome" to your 'thank you' and they'll end up being too embarrassed to ask again.
Good luck!