South African police announced the arrest of 39 leaders of the black nationalist Southwest Africa People's Organization today in Namibia, apparently signaling an end to SWAPO's officially permitted activity inside the South Africa-administered territory.

Although engaged in a guerrilla war against the South African army, SWAPO was allowed to maintain offices and operate as a politcal party inside Namibia, also known as Southwest Africa. It was speculated that today's move may precede a formal banning of the nationalist movement, which receives its arms and training from Communist countries.

The action is likely to elicit a sharp reaction from other SWAPO leaders and further undercut the Western-devised peace plan designed to end the 12-year-old guerrilla conflict.

That plan is now slowly dying as South Africa stalls on implementation because it objects to compromise proposal in the plan. That proposal would permit SWAPO guerrillas to establish temporary bases inside Namibia during a United Nations-supervised cease-fire and election.

The peace plan-a diplomatic initiative of the Carter administration-was aimed at forestalling further Soviet activity in southern Africa by getting a negotiated settlement to the conflict and by bringing Namibia to independence with international recognition, thus averting another Rhodesia-type situation.

In the Namibian capital. Windhoek, a South African-backed political front, the Democratic Turnhalle Alliance, is pushing ahead with its plans to set up an interim government that would have legislative powers.

This is regarded by SWAPO and by the Western powers who have nursed along the U.N. peace plan for two years as a violation of that plan and a clear step toward a unilateral independence that would not get international recognition.

Pretoria appears determined to see the multiracial Alliance, in which whites still retain substantial political power become the independent government of Namibia. The Alliance apparently has failed to get the cooperation of other political parties in the territory, two of which also are anti-SWAPO but anti-South African as well. The Alliance is expected to elaborate on its plans for the interim authority on Monday.

The arrests announced today follow an escalation in SWAPO guerrilla activity that began two months ago when the impasse in implementation of the U.N. plans first became apparent. The upsurge has included the abduction of blacks who cooperated with the South Africans, sabotage of water and electricity lines, the shootings of two white farmers and the recruitment-forced or voluntary, according to conflicting reports-of schoolchildren into the guerrilla ranks.

The South African defense Force has retaliated by bombing SWAPO bases in neighboring Angola and Zambia and by intensifying "follow-up" operations that in the past two days have killed 22 guerrillas, according to the acting commander in Namibia, Brig. P. Bosman.

On Tuesday, Prime Minister Pieter W. Botha said SWAPO would have to choose between its guerrilla operations and its peaceful poltiical activity.

"It cannot have the best of both worlds," he said in Parliament. Botha also told neighboring Angola and Zambia that if they continued giving sanctuary to SWAPO forces, they would "pay dearly for their mistake."

The arrests announced today were ordered under a special law that permits indefinite detention without trial if the authorities suspect a person may cause political violence.

Two top officials of the nationalist organization, its internal chairman, Daniel Tjongarero, and its publicity secretary, Mokganedi Tshabanello, were outside Namibia. Among the 39 arrested are the secretary for legal affairs, Lucia Hamutenya, Vice Chairman Marco Haisiku and publicity official Charles Tjijenda, according to both police and SWAPO sources in Windhoek.