I'm pretty sure that this is an older story, but parts of it have really stuck with me. I read it somewhere in the 1990s, but I think it came from a collection that my parents owned, so it might be much older. It was a short story, part of an anthology (I don't remember the other stories) but it had a psychologist who was trying to prove that it's not necessary to use the carrot and the stick (reward and punishment), but rather that you can just use rewards. He had a device that neurally stimulated the subject with settings for pleasure and for pain (and I remember they were for specific types of pleasure and pain). Odd detail, I remember the machine being described much like a church organ with different buttons for the different pain settings and some method for changing intensities. I also think that the machine was not created by the psychologist, but something mass produced, or at least used in other locations. He was trying to reform a young boy who behaved badly. Through the course of the story, he was trying to only provide pleasure stimulus when the boy acted well, proving his pet theory that punishment was not necessary when teaching proper behavior but it just wasn't working. The boy remained delinquent. Finally, he cracks, and starts using the machine on both himself and the boy (I remember specifically that one of the settings used then involved the pain of "a corncob inserted into the rectum") with him and the boy finally collapsing, crying, beside each other, and the boy becoming much more well behaved.
It's one of those stories which get a lot weirder as you get older. As a kid, I understood it as a "spare the rod and spoil the child" kind of thing. Now, as an adult, I'm looking back on it and it has a very sadomasochistic / pederastic feel to it, especially with the one pain setting involving pain to the anal areas and the psychologist feeling like he needed to suffer with the boy.