Egypt today ordered the Soviet Union and four other Communmist countries to close their consular and cultural offices outside Cairo in measured retaliation for their efforts against President Anwar Sadat's peace initiative with Israel.

In announcing the move, Premier Mamdouh Salem accused the five countries of carrying out subversive actions designed to provoke "a bloddy class conflict" in Egypt.

Th order, which carried no deadline, affects the Soviet consulates in Alexandria, Port Said and Aswan. Also affected are the cutural centers of the Soviet Union, East Germany, Czechoslovakia and Iiungary in Alexandria, and the consulates of East Germany, Poland and Czechoslovakia in Egypt's second largest city.

The notable exception was Romania, a Soviet bloc country which pursues an independent-minded foreign policy and which played an intermediary role between Egypt and Israel in the weeks that preceded Sadat's trip to Jerusalem last month.

Today's action followed Sadat's unprecedented decision to break off diplomatic relations with five hardline Arab critics of his policies who earlier this week concluded a conference aimed at preventing the Egyptian's peace initiative.

The five hard-line states - Libya, Syria, Iraq, Algeria and South Yemen - had accused Sadat of selling out the Arab cause by his visit to Jerusalem and his subsequent decision to hold a conference in Cairo this month to prepare for a new Middle East peace conference. Only Israel, the United States and the United Nations have agreed to attend the Cairo meeting Dec. 14.

[Israel's state television said Wednesday that Israel and Egypt started secret talks a few days ago in preparation for the Cairo meeting, Reuter reported. The television report, which gave no source for its information, said such matters as future boundaries and the Palestinian problem were reviewed in these talks. An Israeli Foreign Ministry official said he had no information on the report.]

While the retaliatory move against the five Eastern European nations was designed to demonstrate Sadat's determination to pursue his policies, it stopped short of an all-out break in relations with Egypt's former allies.

Analysts here emphasized that Sadat's split with the Soviet bloc is not "the other side of the coin of his desire to win U.S. help" for his Middle East peace diplomacy.

Yet, today's move is likely to put additional strains on Egypt's relations with its former Soviet-bloc allies ties already burdened by Moscow's refusal to reschedule Egypt's war debts and provide spare parts for the Soviet-equipped Egyptian armed forces.

While charging that the five Communist countries have been recruiting "loval agents to incite opposition" to Sadat's policies, Premier Salem said they could continue to maintain consulates n Cairo "just as we have consulates in Cairo "just as we have con-countries.

Salem said that the retaliatory step was taken after the Soviets and their allies ignored earlier warnings to cease "flagrant interference" in Egyptian affairs. He said that since Sadat's visit to Jerusalem, Moscow has worked through "its satellites in Europe and the Arab world" to bloc Egypt's policies.

The premier did not provide any details about about acutal incidents of subversion.

Sadat has charged the Soviets with encouraging hard-line Arab critics in an effort to create a rift in Arab ranks. In a weekend statement he had publicly asserted that Moscow "can be punished" for its part in instigating the anti-Sadat meeting in Libya.