Whenever I encounter the "thank you for your service" comment, I try to be gracious about it and remember that the person is simply expressing some genuine appreciation.
I don't figure it's my place to say what I'm thinking, which is a mixture of, "Well, that's nice, but I really didn't do it for you," "Thank you for your service" has become a meaningless auto-response like "Have a Nice Day," and a slight irritation that the Republican party has so thoroughly hijacked military service appreciation that it somehow "taints" an expression of it to some degree. This is all internal, though.
Externally, I always smile and thank the person for their acknowledgement-- usually adding a humorous aside like "Oh, it was my pleasure. Most of the time, haha." One of my standard responses was, "Thank YOU for being a taxpayer all those years--we had some pretty expensive toys back in the day, haha."
I don't need to hear it, and don't even particularly want to, but I never make a person sorry they said it. Mentally, I usually remind myself that in a very tangible way I'm "accepting" this appreciation on behalf of service members I knew, or for that matter didn't know, who aren't around to hear it for themselves...which is another reason to accept it graciously and move on.