When someone says something unpleasant or rude, often the reply is "Bite your tongue!". But where did this come from? I can find a number of sources explaining that to bite one's tongue is to hold it between the teeth, preventing speech, and thus is a metaphor for not speaking; this makes sense, as I've seen "I bit my tongue" to mean "I didn't say anything". However, I can't find much about the usage as a response to something already said. Is it along the lines of "You should have bit your tongue instead of saying that"? Are the two usages actually related or just similar?
For clarification: usage A of the phrase "bite your tongue" is a synonym for "hold your tongue", whereas the usage I'm interested in is used similarly to "Wash out your mouth with soap" (though that's usually used for swear words, whereas this can be used for any negatively-perceived statement, like saying something bad about a public figure who is well respected, or implying that a woman is over a certain age)