Soviet President Nikolai Podgorny extended his African tour yesterday with a visit to Somalia, where Moscow maintains major naval military and military installations.

The trip was a departure from Podgorny's announced African itinerary which has included stops in Tanzania, Zambia and Mozambique. The Soviet news agency, Tass, said Somali President Mohammed Siad Barre had invited Podgorny to call on his return home. The agency said the two would have an "unofficial" meeting.

Somalia, an impoverished nation of 3 million, is on the coast of East Africa at the strategically important entrance to the Red Sea. The Soviet Union has established an important naval base at Berbera.

A joint Soviet-Mozambique communique was issued yesterday after Podgorny's visit there. It called for an international arms embargo against South Africa and urged that a "zone of peace" be established in the Indian Ocean.

Cuban President Fidel Castro ended his month-long visit to Africa yesterday and flew to East Berlin, where thousands of Communist youths cheered him in a flag-bedecked parade.

Castro's African tour took him to Libya. Somalia, Tanzania, Mozambique, Ethiopia, Aden, Angola and Algeria.

Meanwhile, usually well-informed sources in Maputo, Mozambique, reported that the "front-line" states opposing the white-minority government in Rhodesia will meet Sunday in that city. The discussion will focus on the Castro and Soviet visits, the sources said.