Scheduled to depart on August 18th, Erdoğan will arrive to Somalia on August 19th accompanied by his family and the Somali President Sheikh Sharif Ahmed.
Visits by world leaders to Somalia are extremely rare due to the extreme security risks, but Erdoğan was undeterred.
"It is impossible for us to be spectators to the human tragedy in Africa," Erdoğan said.
"My foreign minister and I will visit Somalia with our families. So, we will get a chance to see the situation there," Erdoğan told a meeting of the ruling Justice and Development Party (AKP) in Ankara.
It is especially dangerous to visit the Somali capital Mogadishu after Islamist rebels mostly pulled out last weekend, raising the spectre of more guerrilla-style attacks such as suicide bombings after their failure to win a military combat.
The government and African peacekeepers admit they do not control all of the capital even after the rebels' withdrawal.
The last leader to visit was Ugandan President Yoweri Museveni in November last year.
His army contributes more than half of a 9,000-strong African Union peacekeeping force propping up the government. But no one from outside Africa has been for a very long time.
Istanbul will host a meeting on Aug. 17 of the 57-nation Organisation of the Islamic Conference aimed at galvanising support for Somalia and drought-struck neighbouring regions.
The meeting, which comes during the Muslim fasting month of Ramadan, was proposed by Foreign Minister Ahmet Davutoğlu.
Turkey sent two cargo planes laden with 50 tons of food and medical supplies to Somalia on Monday and the Turkish Red Crescent is working with the government's development agency and Office of Religious Affairs to raise donations from the public.
Turkey, with its multi-party democracy and rapidly growing economy, is widely regarded as a model for development in other countries of the Muslim world.
Erdoğan's wife, Emine, visited flood-stricken areas of Pakistan last year, raising Turkish awareness of its people's plight. Turkey's speedy response to disasters has strengthened reputation within the Islamic and developing world.