This is a relatively common story, it showed up in my university textbooks, for one thing (as an example of the spartan mindset, not as a true story).
The way I heard it, the boy (as were all spartan boys) lived in a military training school, and like all boys was kept hungry, to encourage craftiness and toughness. He had stolen a fox (to eat. Presumably it was kept alive so the flesh wouldn’t go bad.)
But befor he could secure his prize, there was an inspection, meaning that he had to stand in line, absolutely still. Rather than facing the shame of flinching during inspection, and of being caught read-handed stealing, he kept still, and the fox, stuffed under his tunic, killed him. He was remembered as a rolemodel for all boys to follow. The Spartans idealized the ability to withstand pain or hardship without showing the “weakness” of flinching or making a sound.
And as Paul in Saudi pointed out, the boys were never punished for stealing, if anything it was encouraged. But the punishment for being caught was severe. The purpose for this might have been to encourage boys to develop observational and tactical skills (where is the food? when is it guarded?), as well as the ability to live off whatever you can find. So the boy will have had plenty of reason for doing what he did, or rather, the story has a very usefull moral for a society like the spartan one.
A similar story, one that is slightly more likely to be true, is that of the grown man who had been convicted of something, and was to be flogged. The man who flogged him, or the judge, wanted to force him to shame himself, and so ordered the flogging to continue until he cried out in pain. However, no matter how much they flogged him, he did not make a sound, and died before the beating stopped.