What distinguishes 教师 (jiàoshī) and 老师 (lǎoshī) which both mean "teacher"?
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 教师 - 教师节.