선생(님) means a teacher in general - it can also be used to call a random person (who is a bit in their older ages) with respect. On the other hand, 교사 means an instructor as a professional occupation and is an official term used to refer to teachers formally from a structural and organizational perspective, so students don't call their teachers 교사 but 선생님. However, it is good to remember those two words are used interchangeably case by case (But the fact that students always call their teachers 선생님 not 교사 doesn't change. )