At Chapman School in Nebraska, resourceful students hawk pizza and cookie dough to raise money for school supplies, field trips and an eighth-grade excursion to Washington. They peddle chocolate bars to help fund the yearbook.

But the sales won't be so sweet starting this fall. Campus bake sales—a mainstay of school fundraisers—are going on a diet. A federal law that aims to curb childhood obesity means that, in dozens of states, bake sales must adhere to nutrition requirements that could replace cupcakes and brownies with...