The insurgents had taken shelter at the school compound in the central eastern province of Wardak, 35 km (20 miles) southwest of the capital, Kabul, when the airstrike hit late on Wednesday, the officials said.
International forces that conduct most of the air strikes across the country were not immediately available for comment.
Abdul Rahman Mangal, a spokesman for the governor of Wardak, said there were no civilian casualties, adding that all the pupils had gone home before the air strike.
Foreign troops have stepped up air strikes in Afghanistan in recent months as Afghan forces struggle against a resilient Taliban insurgency.
The Taliban are seeking to reimpose strict Islamic law after their 2001 ouster by US-led troops.