By doing it with sincerity and without an ulterior motive.
Unfortunately, the latter especially, rarely exists.
But how do you judge sincerity and how do you know that the person complimenting you just wants bed action and nothing else?
Thinking back to when I was clubbing with my mates it was difficult enough to approach a girl without having to worry about showing sincerity.
Telling someone that you find them attractive should be taken as a compliment or would you rather men not approach you at all?
That's the thing about sincerity though, isn't it? You don't need to try being (or sounding) sincere, if you are, then you are. And it will be apparent to whoever you're talking to.
Everyone likes being complimented, so don't let my comment put you off complimenting people.
It's the people that do it purely for their own gain, in my case to sell me something, that really get my goat.