The European Parliament moved today to defuse a controversy over the 40th anniversary of the Allied victory in World War II by voting to host a ceremony that will include an address by President Reagan.

U.S. and West German officials announced that Reagan would curtail a planned state visit to West Germany to address the European Parliament in Strasbourg, France, on V-E Day, May 8, the date the unconditional Nazi surrender took effect. The surrender occurred the day before.

Political analysts said that the switch of plans was designed to avoid embarrassment that might have arisen had the commemorative ceremonies been a bilateral U.S.-German occasion.

By associating the European Community with the anniversary, it will be easier to promote the theme of peace and reconciliation in Europe.

Officials at the European Parliament, a relatively powerless "talking shop" made up of directly elected representatives of the 10 European Community countries, said it had not been decided whether other western leaders would be invited to the May 8 session. Leaders of the leading noncommunist industrialized nations will be meeting in Bonn May 2-4 for their annual economic summit.

One official speculated that Italian President Sandro Pertini might attend in his capacity as the current president of the European Community -- a post that rotates among the heads of state. Although his country was an ally of Germany during the war, the 89-year-old Socialist president had a distinguished personal war record as a resistance fighter.

In London, British officials said it was "highly unlikely" that Prime Minister Margaret Thatcher would be present in Strasbourg for the anniversary, as she is expected to attend a commemoration service in Westminster Abbey.

The main concern of the West German government was to avoid a repetition of the situation that occurred last year when Chancellor Helmut Kohl was not invited to join Reagan and other western leaders in joint ceremonies commemorating the 40th anniversary of the allied landing in Normandy.

Bonn government spokesmen insisted today that they were not offended by Reagan's decision to cut short his state visit by two days. The president now is to leave Bonn May 6.

U.S. officials said that they did not know where Reagan would be spending May 7. The president originally had planned to travel to Spain and Portugal after his state visit to West Germany.

A White House spokesman said those visits were still planned, but the timing was uncertain. He said Reagan would return to Washington May 10, earlier than previously envisioned, because of "legislative and other domestic agenda items."

According to European Parliament officials, the decision to invite Reagan to address the assembly was made at the instigation of Washington. U.S. officials are reported to have made clear through diplomatic channels that the president would accept such an invitation if one were issued.

The address will provide Reagan with an opportunity to call for cooperation between the United States and Western Europe as well as being seen to endorse the principle of European unity. U.S. officials also hope that it will be regarded as less of a snub to the Soviet Union, an erstwhile wartime ally, than would a ceremony in West Germany.

The Soviet Union has already embarked on a program of commemorations designed to show that its armies played a dominant role in the overthrow of Nazi Germany. Soviet propagandists have complained that the West systematically has played down the contribution of the Red Army in grinding down 250 German divisions on the eastern front before the opening of the "second front" in Western Europe.

The European Parliament's decision to invite Reagan was criticized by the West German Greens party and Italian Radical Party today. The decision to hold a special ceremony to commemorate the anniversary was, however, passed by 138 votes to 10 with six abstentions.

West German Christian Democratic deputies, who earlier had opposed the idea of special commemorations, decided to support the resolution after it was announced that Reagan would be invited to give an address.