WASHINGTON (AP) _ White House spokesman Larry Speakes said today that Kurt Waldheim, as Austrian chief of state, would be exempt from U.S. law that bars anyone who participated in World War II Nazi persecutions from entering the United States.

A Justice Department spokesman said earlier the exemption would apply only as long as Waldheim is president.

Speakes, asked to respond to the election, said: ''The people of Austria have made their choice in a free and democratic election. The United States will continue our close, friendly relations with Austria.''

The White House spokesman said the United States is obliged to pursue an investigation of allegations concerning Waldheim's Nazi past ''to see if the legislation applies.''

''But someone who is a chief of state is exempt from this legislation,'' he added.

Asked for Reagan's view of the allegations against Waldheim, Speakes noted that the matter was under investigation by the Justice Department and said Reagan ''has not prejudged the allegations.''

He said President Reagan planned to send ''the usual diplomatic letter'' to the new president later in the day.

Waldheim, 67, won a resounding victory in Austria's presidential election Sunday, after a campaign during which he denied hiding a Nazi past involving atrocities.

Waldheim's victory will not affect the Justice Department's deliberations on whether to bar him from entering the United States, department spokesman Patrick Korten said in a telephone interview Sunday.

But if the verdict goes against Waldheim, it would not be in force as long as the former U.N. secretary-general is Austria's president, he said.

''The laws provide foreign heads of state with diplomatic status. In addition, there are diplomatic exceptions in the immigration laws,'' Korten said.

''As a result, it is quite clear that for the time that he holds the office of president, he'll be entitled to that status, regardless of what action we take,'' Korten said.

Following a probe two months ago of allegations that Waldheim committed war crimes while stationed in the Balkans during World War II, Neal Sher, director of the Justice Department's Office of Special Investigations, recommended that Waldheim be put on the watch list.

A 1978 law allows the United States to exclude aliens who were associated with the Nazi government and in any way participated in the mass executions of Jews and other ethnic groups during World War II.

According to Sher's report, war records show Waldheim was a special missions staff officer in the intelligence and counterintelligence branch of the German Army's Group E, which was involved in reprisals against civilians in the Balkans. The army group was commanded by German Gen. Alexander Lohr, who was hanged for war crimes in 1947.

Waldheim has denied he was involved with any attacks on Yugoslav partisans and says he had nothing to do with and no knowledge of the deportation of Jews from Salonika, Greece, to Nazi death camps. He has, however, acknowledged that he did not reveal the full extent of his wartime service record until the recent controversy.

Justice Department officials said last week that no decision on whether to bar Waldheim would be made until after they had met with Waldheim's lawyers to give them a chance to rebut charges.

Korten said a date had been set for that meeting, but declined to disclose it, saying only that it would be ''in the relatively near future.''

Some Justice Department officials had said earlier it was uncertain how Waldheim's election would affect the actual implementation of any ban, but Korten said ''that was always clear.''

''It is entirely possible that the decision (to put hm on the list) would be in the affirmative, but he would still be allowed to enter freely,'' Korten said.

The Justice Department has denied that politically motivated foot-dragging was responsible for the postponing of a decision until after the election, and Korten said the fact that Waldheim won will not play a role in the decision- making either.

''All of this has been done without any attention given to when the election was. We'll make the decision after we have the information in hand,'' Korten said.

He acknowledged, however, that it would be ''unprecedented'' to bar the president of a friendly country. There are about 40,000 people currently on the watch list, Korten said, none of them heads of state.