As I guess, the word 'sir' is to call a man whose position is higher or whose age is older. For example like school principal (and I am a student of the school). And one day when I was watching a movie, I heard the actress playing a station employee called a man who was buying a ticket 'sir'. So I think 'sir' is also used to call a stranger.
But what I wonder is, I am learning English and there is a male teacher. And I learned that I can just call teacher his/her name. So I am kind of confused because when to use the word 'sir'. I'd like to know appropriate situations to use that word. Only relationships between teacher-student / clerk-costomer / superior - subordinate?