The two all-white Dutch Reformed churches that claim the loyalties of more than half of South Africa's ruling white Afrikaners were voted out of the World Alliance of Reformed Churches last night for the "heresy" of racial segregation.

Following more than six hours of anguished debate and prayer at a meeting in Ottawa, the international body voted 221 to 20 with five abstentions to suspend the Nederduitse Gereformeerde Kerk and the Nederduitse Hervormde Kerk.

Support of South Africa's strict segregationist policy of apartheid by the two churches, offshoots of the Dutch Reformed Church brought by settlers to Africa more than a century ago, has long been a sore point among Christian churches in other parts of the world. Last night's action by the Alliance, which has nearly a dozen U.S. denominations in its membership, climaxed years of warnings and resolutions condemning apartheid.

The blow to the segregated churches is expected to be compounded today when the Alliance elects its new president for the next five years. The only nominee is the Rev. Alan Boesak of the Colored, or mixed-race, branch of the South African Reformed Church.

Boesak is chaplain at the predominantly Colored University of the Western Cape, the Sendingskerk. His election, which Alliance leaders say virtually is assured, would make him the first nonwhite ever to head the 107-year-old Alliance.

It also would enhance the prestige of the articulate and politically astute Boesak, who has been a consistent stab to the consciences of the white Afrikaners on the race issue.

The Alliance is an international grouping of about 150 churches of the Reformed, Presbyterian and Congregational traditions in 76 countries. Formed in 1875, it has no juridical authority over member churches but promotes international cooperation among the churches and provides a forum to resolve debates and unify church practices around the world.

Suspension of the two churches, the moral arbiters of South African life, is expected to deepen divisions between Afrikaners and Coloreds in South Africa at a time when Prime Minister Pieter Botha is trying to draw them together.

Last night's vote leaves South Africa's white churches virtually isolated from the rest of the Christian world. They withdrew from the World Council of Churches more than a decade ago because of the council's stand against racism and its financial support of organizations fighting racism and white domination.

The Afrikaner churches broke off from the Netherlands mother church and the South African Council of Churches for the same reasons. Dropping out of the South African council also has isolated the Afrikaans churches from the rest of South Africa's churches--Roman Catholic, Anglican, Methodist and Congregational -- all of which have condemned apartheid.

In South Africa, the political influence of the white Reformed churches has been likened to that of the Roman Catholic Church in Ireland. It is not directly exercised, but the churches' capacity for moral persuasion is enormous.

White South African delegates at the meeting of the Alliance fought the suspension during yesterday's debate, according to accounts of the closed meeting. Prof. John Heyns of the Nederduitse Gereformeerde Kerk offered a lengthy review of the "improvements" he said the churches had made in their racial stance over the years and likened the proposed suspension to "being amputated, like an arm with cancer. But sometimes amputation does not heal, but stimulates the disease."

The Rev. Dr. Avery Post, president of the United Church of Christ in New York, called the action a "joyless but moral necessity," saying "Where the word of justice is muffled by the church, God weeps and mourns."

Three conditions were set for lifting the suspension: that "black Christians are no longer excluded . . . especially from holy communion" in South Africa's white churches; that the churches adopt a formal "unequivocal" statement rejecting apartheid in both church and politics; and that they provide "concrete support, in word and deed" for "those who suffer under the system of apartheid."