The phrase “go back on your word” is usually used to refer to someone doing something that they said they wouldn’t do, or not doing something that they said they would do. I.e. they gave their word and now they are violating it.
In your example here it sounds like the teacher is trying to tell the student not to retake the test. This is not an instance where anyone’s word is being violated; rather, it is an instance where the student has a misguided desire. The teacher wants the student to take back his words, or retract his words so that it doesn’t count as an official decision to retake the test, which the teacher knows to be a bad decision.
If for whatever reason the student continues to say “I will retake the test” and then he changes his mind, it would then be appropriate to say to him “you can’t go back on your word”.