I read this short story in my English schoolbook, ca. 1995. It's possible it was written specifically for the schoolbook but it had some "mature" feel to it which makes me think it might have been published somewhere more conspicuous than a mere schoolbook.
In the first half of the story, a prison warden shows off a new kind of prison to a reporter. The prison has no walls, instead the prisoners have an implant which induces pain if they walk away, the pain level growing slowly with distance. During the showing, one of the prisoners actually walks off, until he finally doubles over and drops to the ground from the pain. He is then brought back to the prison.
I remember the warden at some point chiding the reporter for saying something that "sounds commie", whereupon the reporter profusely apologizes to the warden.
The second half focuses on the prisoner who walked away in the first half. (His name might be "Revell" though I may misremember that.) He walks away again, but this time he is not picked up (deliberately, if I remember correctly). He crawls away and is finally found by some random passer-by who, not knowing he's dealing with a prisoner, takes him to a doctor. (I remember "you hurt, fella?" as part of the dialogue.)
The doctor performs surgery to remove the pain inducer. For this, the doctor is sentenced to the same prison. The story ends with both the original prisoner and the doctor walking away together.
At some point during the story, the prisoner sings a song: "Twinkle, twinkle, little pain, in my groin and in my brain."
Googling I mostly get references to The Fortress (which features similar but more deadly implants). With the rather distinctive song lyrics, I found at least one obscure reference to possibly the same schoolbook. (Which, IIRC, had a very boring name like "English C", I think. It was a blue hardcover with some kind of photograph on it.)