In response to the detention the agency halted food distribution to 75,600 Mogadishu residents who have been displaced by fighting that has persisted since the interim government and its Ethiopian allies forced the Islamic Courts movement from the capital last December.
Ali Mohamed Gedi, the Somali president, said last week that Osman was under investigation and would be released only if he was found innocent.
There was no explanation for his release on Tuesday but Josette Sheeran, the WFP's executive director, welcomed it in a statement.
Sheeran urged the Somali government last week to provide protection for its workers.
About 1.5 million Somalis need food aid and protection presently.
That number is 50 per cent higher than at the start of the year due to inadequate rains, continuing internal displacement and a potential cholera epidemic, according to the UN.
Somalia has not had a functioning governments since 1991, when rival factions overthrew the then authoritarian leader Mohamed Siad Barre and then began fighting each other.