The method/perspective under which this treatment falls under is aversive conditioning.
This means that each time a person wants to do something he or she is not supposed to do, they will experience an uncomfortable stimulus that will help them associate that bad thing with the bad experience. This way, they will no longer want to do that bad thing because it will remind them they will experience pain along with that.