The idea is simple, really: take your subject, who tends to engage in some behavior, and sit him down in front of a projector. Give him nausea-inducing drugs
or strap some electrodes
on him and show him pictures of people performing the behavior. Shock him, or wait for him to get nauseous, and continue with the pictures. Eventually, the subject will learn to associate the behavior with pain, and will no longer pursue it.
This brutal but effective psychiatric technique was employed throughout the 20th century, most notably as a cure for homosexuality. It is seldom used for this purpose now since homosexuality is largely no longer regarded as a crime. It was spotlighted in the film Clockwork Orange, wherein the protagonist undergoes aversion therapy for violent criminal activity.
Recently, aversion therapy has enjoyed a limited comeback as a treatment for cocaine and nicotine addiction. The technique is more sophisticated, involving the introduction of drugs into the subject that will react with the drug to be "averted," causing nausea or other pain when the subject snorts coke, or smokes a Marlboro, or whatever.