Perhaps learning time & place? I’m not saying what was stated was correct, but maybe knowing where not to say inappropriate things could be a start? It doesn’t punish the offense, but it might make him pause on his own. It’s a filter of a different sort that he might not find as stifling or restricted. Then he might learn what not to say as he gets older.