People sometimes say sir as a very formal and polite way of addressing a man whose name they do not know or a man of superior rank. For example, a shop assistant might address a male customer as sir .
You use the expression Dear sir at the beginning of a formal letter or a business letter when you are writing to a man. You use Dear sirs when you are writing to an organization.