Employees who deal with the public, like cashiers, receptionists, security guards, hotel staff, etc. often call male customers "Sir". It's supposed to show respect. For example:
Sir, can I get you something to drink while you wait?
In the U.S., you can also call any adult man who you don't know "Sir".
On the other hand, it's a little strange to call someone "sir" who you know well, like a coworker or friend. Unless someone has a clear position of authority over you (like a teacher), don't call him "sir" if you've had friendly conversations with each other.
The equivalent title for women is "Ma'am".