Seems like it's a common question. 现代汉语规范词典 has a note, about it, on it's entry for 老师:
注意 跟“教师”“教员”不同。“老师”可以接受表示人的名词或人称代词的限定, 如“小王的老师”“她的老师”; “教师”“教员”不能这样用。“老师”是称谓词, 适用范围宽泛, 还可用来称呼其他行业的某些专业人员; “教师”“教员”是职业名称, 仅指担任教学工作的专职人员。
老师 can be a noun or personal pronoun, as in “小王的老师” (Wang's teacher) or “她的老师” (Her teacher) - “教师” and “教员” cannot be used this way.
老师 can also be used, with a broad scope, as a title and can be used to call professionals in different capacities - “教师” and “教员” are professional designations that only refer to school teaching personnel.
On a side note: this reminded of people from 重庆 - you'll often here 重庆 people refer to each other as 老师 as a simple term of respect - it's their equivalent to sir/ma'am.
Formal terms like Teacher's Day use the word 教师 - 教师节.
教师 teacher (general term)
老师 teacher (general or affectionate term ; honorific)
You can say either '一位教师' or '一位老师'. Both mean 'a teacher'
You say '我的老师' (my teacher) to show your respect and fondness. Saying '我的教师' lack both .
We address our teacher with the honorific 老师(Sir). For example: "老师! 早上好"(Good morning, Sir!)
You cannot use the general term "教师!" to address your teacher. Saying "早上好, 教师" (Good morning, teacher!) is unacceptable.
The easiest way to distinguish is that 老师 is a pronoun and an honorific, but 教师 is a noun specifically referring to the occupation. Basically,
means Mr. (Teacher) Wang is a fantastic teacher.
Note that 老师 is the more general and common term that it can be used in both ways. 教师 on the other hand is more formal title for the occupation.
It's a straightforward matter of status. 教师 is a job. 老师 is a profession.
A 教师 is on the school's payroll but is not a parking lot attendant.