Its a challenge dude!
Good education helps learner develop 'faith' (in oneself), 'sensitivity' (for others) and 'expression' (of what one knows/learns). Its just teacher wants learners to speak in 'certain' way and on 'certain' topics, students will not develop the third skill and in any way it is undemocratic way of teaching. A teacher punishing students for talking in the class is like a stopping plants to grow while watering them! Listen to what the speak off the topic and relate it to with the topic, if you can! Its a challenge dude!