The form of behavior therapy in which an undesirable behavior is paired with an unpleasant stimulus to reduce the frequency of the behavior is called aversion therapy.
Aversion therapy purpose is to associate a bad habbit with unpleasant effect so the patient will gradually stop doing it.
For example, to make children stop biting their nails, you could put a sour substance on it so they will taste it whenever they try to bite their nails.