This is something Alice (who is quite a bit younger), as well as a number of students (who were also, mostly middle school students) I have had have struggled with.
Let me preface this by saying, I know Beofett is asking with a friend in mind, I am going to write this as if I am speaking directly to the parent just for the sake of simplicity.
Kids do have to learn how to figure out when to intervene in certain things and when not to and this can take some time. It is still difficult even for some high school kids, and frankly, even for adults in particularly complex situtations. Kids with parents that offer guidance, support and loving feedback along the way, probably often "get it" more quickly or better in the end (but I don't have specific research to back that up).
For The Adolescent In the Question
During your conversations about this, make sure your child knows that seeking quiet while trying to learn is not wrong. Sticking up for his/her needs is not wrong (it is called being a self-advocate). Trying to help a friend stay out of trouble is not wrong either and that you are proud of your child for making decisions with these things in mind. However, you may also find it helpful to point out to your kid that there are ways to do the above three things that are more likely to result in resistance/argument and other ways to do these three things that are more likely to "work."
Asking some questions and finding out exactly what and how the child spoke to the other kids (in a calm, loving tone) may help a parent find ways to guide a child to a "better" way to get what they want. For example, with Alice, she often "corrects" others because she sees it as a helpful thing to do - she is trying to help them not get into trouble. Young kids might word something like this as, "You guys need to be quiet or you'll get into trouble." and really mean it at the face value of what they said. Meanwhile the child/children at the receiving end of the "correction" hear a threat and an intervening teacher in a bad mood, with too much to do who is tired of interruptions might also react unprofessionally and poorly without even giving it a moment's thought.
I might offer up the following concept (though maybe not this specific wording) for discussion with your kid as well - especially if you think shades of the idea might be applicable in this situation, but over time all kids should have the following "idea" conveyed to them in some way or another:
Sometimes, being a "tattle tale" is absolutely the right thing to do.
Lets consider an adult situation - coming to the aid of someone in the middle of a burglery at gun-point may not be the safest way to get help. At the same time, it isn't right to simply walk away and do nothing either. In this circumstance, being a tattle-tale and calling the police for help is most likely the best way to get help for the victim without getting yourself hurt.
One of my former teen students came to me to report her friend was likely to attempt suicide over the weekend (This girl's friend had even already obtained the means with which to do it and had a plan worked out) - thank God that child was a "tattle tale." At the same time, going to a teacher to say, "so and so called so and so a jerk." Probably isn't really helping anyone and kids need to learn to stick up for themselves and/or problem solve for themselves a little bit too.
Then, contrast the idea with examples where "telling" is really just about getting someone in trouble or exacting revenge - something that is definitely not helpful. There is also a range of in-betweens that could be discussed. Discovering or creating some differing examples and debating whether to "tell" or not to "tell" and what to do if "telling" isn't appropriate can be a really good exercise for kids. Having these kinds of discussions in an impersonal way over dinner is also a great way to show your adolescent how much you recognize about his/her growth. By discussing more difficult issues and asking them for their thoughts, they get exercise with tougher situations and see an example of you seeing them as more than a "kid." Plus, you still have the window of opportunity to offer your own thoughts and feedback too. I actually did this kind of thing with my eighth grade guidance groups and sometimes helped them "role play" situations with each other in a supportive environment.
With Alice (who is only seven), I've worked a lot on teaching "I messages" for the times when she really needs someone else to be quiet or follow a rule for her own reasons. "So and so, I'm really trying to understand this and I can't hear what the teacher is saying. Can you please be a little quieter" might mean she comes across as a total nerd, but she definitely won't come across as a "tattle-tale" or "goodie two-shoes." A confident nerd, can be proud of her nerdiness after-all and you do catch more flies with honey . . . i.e. "I" messages often just work better in these types of situations than anything else. I also taught this technique to my "homeroom, advisory group or guidance group" depending on the school and in particular taught to kids that needed to self-advocate with other kids, their parents, or other teachers for one reason or another.
For situations where Alice is trying to help out a friend or acquantance, there are some subtler nuances, we haven't quite figured out how to help her with yet, but for the most part, teaching her to lead with, "hey, maybe you don't know about the _____ rule. Would you like me to explain it to you?" (or something like it) comes off as much more "helpful" in intention. For older kids, that can get more of the nuance, I'd recommend a more sophisticated wording, but that is how we've talked about it with Alice up until now. If the child doesn't want the help, she has been taught not to offer it - let the kid get themselves into trouble, they are knowingly breaking a rule and choosing to break it at that point. We are still working on how to help her figure out when to just not say anything and it may be that she just needs time and experience for that.
With the Teacher
The moment may have been so meaningless to the teacher (trust me, there are some "choice" people that have managed to get into the profession as well as some that truly are grade-A top sirloin), that he/she may not even remember it. At the same time, the comment may have come because the child in question is often trying to "help" others by reminding them of the rules and there may actually be a latent irritation even by the teacher over the matter. For this reason, I do suggest bringing the topic up with the teacher.
Much as Chrys points out, there is likely more to the story than we realize, so approaching the teacher with questions as opposed to accusations is a tact that will leave you much more informed (this likely includes feedback you can give your child in a much more loving way than the teacher did) and as James Snell points out, approaching this with an "ask" attitude rather than a "tell" one means you are more likely get you better results because you do catch more flies with honey. . .
Once you've heard the teacher's side of things, you can react accordingly using the same kind of "I" messages I suggest teaching to your child, just instead they'd be "we" messages -
for example, "I was just concerned about the encounter because Johnny seemed really taken aback by your statement about being a tattle-tale."
"I feel Johnny did not understand what it was he did wrong in the situation, and from what he has told, me I can't figure it out to help him understand either - could you tell me more about it?"
"I am concerned that because you confronted him in front of the whole class and so quickly he was left feeling confused and unable to ask questions of you. In the future, could you find a way to correct him more privately or, if you don't have the time for that, email me about things rather than confronting him in this way so that I might be able to take more time to explain things?"
As someone else mentions, it is always smart to make a record of the date and time of your conversation and at the very least, the topic you discussed and the concensus you came out of the conversation with. Just in case further problems crop up, it never hurts to have a record with dates and at least the "jist" of what was discussed if not a transcript (which can be hard to get without seeming too "official" about it. Keep all emails though
For the Parent
Don't stress too much about one teacher. Yes, they spend a lot of time with your kid, but only for one year. Over the long-term, the parents are still the most influential people in the life of a growing child, and often in the resulting adult as well. One flippant remark made by a teacher in an unprofessional (no matter how justified the statement may actually have been, name-calling your students is definitely something there is no excuse for) moment will not determine the type of child your kid will become. This does not undo all your work, it is simply a temporary set-back. Just the fact that your son shared this experience with you means he gets the teacher was wrong.