Nigeria's head of state said today that any company seeking to invest in Nigeria must satisfy his government that it does not do business with South Africa or has a program of gradual withdrawal from South Africa.

Lt. Gen. Olusegun Obasanjo said one West German company recently complied with Nigeria's policy by providing evidence that it was phasing down its business in South Africa.

Nigeria, the richest and most populous black African nation, has become a leader in efforts to topple the continent's two remaining white governments - Rhodesia and South Africa.

Obasanjo told reporters that the question of multinational corporations that have subsidiaries in Nigeria and South Africa is "a different kettle of fish."

His government is collecting information about such companies and will make its decisions about their future after further study, the Nigerian leader said.

Because South Africa's policy of racial separation, apartheid, is a philosophy that the entire world should fight, Obasango said. Nigeria is prepared to sacrifice its own development by refusing to cooperate with multinational corporations if those corporations insist on continuing their investments in South Africa.

Obasanjo is the first Nigerian chief of state to visit the United States and his talks with President Carter earlier this week marked the major improvement in U.S.-Nigerian relations that has taken place since the late 1950s. Last year, Obasanjo's government refused then-Secretary of State Henry A. Kissinger's repeated requests for permission to pay a visit to Nigeria.

Nigeria's wealth comes from the 2 million barrels of oil it produces daily, more than half of which is imported by the United States. Nigeria is the United States' second-largest supplier of foreign oil after Saudi Arabia.

Obasanjo said that when Carter raised the question of oil prices with him he replied that they must be linked to other prices. A reduction in world oil prices would have to be accompanied by a reduction in prices of manufacturer goods, he said he told the President.