Is it ok? It is definitely ok!
There are so many factors that a TD has to take into account, and all situations that we encounter are, by definition, highly situational! There is a reason why we don't have one set penalty for all infractions -- we have to make a judgment call each and every time as to what an appropriate penalty is for any given situation. In my opinion, you would actually be doing the players a disservice by assessing the same penalty for different infractions under different contexts.
I don't see the approach as being much different from judges who apply the law: you hope that the "punishment" assessed by a judge will fit the "crime". Of course, poker is not so serious, but you get the idea. Two people can commit the same act, but receive different punishments because of their prior record or lack thereof, for example; not unlike the possibility that you might assess different penalties for rules infractions at the poker table based on player history. Furthermore, when two acts are similar but different in some way, it is completely fair that the more serious act be assessed a harsher penalty.
In your examples, I do not even see the situations as being "similar" at all. In the second example, the action involves clearly making a targeted, derogatory comment. This act evolved into a confrontation that did not cease even when the TD arrived, which suggests that the situation was beyond the level of a few words being exchanged back and forth. Finally, the first situation, as you noted, involved a novice player -- which I think is relevant (unless the TD had given these players a prior warning).
I have no problem with the TDs ruling here. It sounds like the player who has been assessed the penalty is suffering from "sour grapes" syndrome. You can't stop him from threatening to complain to a higher up, but have solace in the fact that if he is making such a big deal over a two-hand penalty, and cannot man up and acknowledge that it's inappropriate to be calling people "dogs" in the first place, the decision was probably the right one.