A spokesman for Abdullahi Yusuf, the country's president, said: "We wanted to do some reshuffling due to the factors on the ground. We are hoping they will both fulfil their jobs well and do something about public health."
Abdi Hassan Awale, popularly known as Qaybdiid, was one of the last of a group of US-backed commanders to surrender to Islamic Courts fighters who seized the capital last year before being ousted by allied Somali-Ethiopian troops.
Dheere was the self-appointed local governor whose forces secured Jowhar, 90km north of Mogadishu, as a temporary base for the interim government in 2005.
Both men inherit major challenges; fighting in the capital over the past nine days is being described as the heaviest for 16 years.
However, it remained unclear whether the fighters had been defeated or melted away to regroup.
Some homes and commercial properties have been looted.
The UN has warned of a looming catastrophe in the country with more than 365,000 people leaving the capital since February.
Most of the refugees have moved surrounding areas already ravaged by drought and then swamped by floods.
The UN says the displacement rate in Somalia over the past three months has been worse than in Iraq in the same period.
The AU wants more peacekeepers sent urgently to support a vanguard of about 1,500 Ugandan troops, who have so far been restricted to guarding sites such as Yusuf's office and the air and sea ports, and to treat wounded civilians.