NICOSIA, Cyprus (AP) _ Iran said Tuesday that two West German diplomats have been ordered out of the country in retaliation for a television spoof of Ayatollah Ruhollah Khomeini.

Its official Islamic Republic News Agency said the two were told to leave within 72 hours.

''The decision was made by the Iranian Foreign Ministry following a broadcast on West Germany's national television network mocking Islam and the leader of the Islamic revolution, Imam Khomeini,'' IRNA said.

Ambassador Armin Freitag of West Germany was summoned to the Foreign Ministry and ''handed a strongly worded protest note on the insulting program,'' together with the expulsion order, it added.

Juergen Chrobog, spokesman for West Germany's Foreign Ministry, confirmed the expulsion and said: ''We regret the decision of the Iranian government.''

Iran did not identify the diplomats, but Chrobog said they were Ruprecht Henatsch, the ambassador's permanent representative, and cultural attache Guenter Overfeld.

A 14-second segment Sunday night on the Rudi Carrell comedy show, one of West Germany's most popular programs, started the diplomatic flap. It used camera tricks to make exultant women appear to be throwing their underwear at Khomeini's feet.

The Iranian Embassy in Bonn protested and the West German Foreign Ministry expressed regret, but stressed that the government guarantees press and artistic freedom.

Last November, Iran expelled three Italian diplomats and temporarily recalled its ambassador to protest a spoof of Khomeini on Italian state television.

Iran's consulates in Frankfurt, Hamburg and Berlin were closed Monday in protest and remained shut Tuesday, Foreign Ministry officials said. The embassy in Bonn was open.

Chancellor Helmut Kohl's government has been seeking Iran's help in freeing two West German hostages being held in Lebanon. Government officials believe they were seized by Hezbollah, a fundamentalist Shiite Moslem group with close ties to Iran.

Kidnappers seized the West German businessmen after the arrest in Frankfurt of a Lebanese suspected of terrorism. The United States wants him extradited on murder and air piracy charges in the June 1985 hijacking of a TWA jetliner to Beirut, in which U.S. Navy diver Robert Stethem was killed and 39 Americans were held for 17 days.