President Alvaro Magana of El Salvador will visit Washington for talks with President Reagan on June 17, the administration announced yesterday.

The invitation was extended last December, when Reagan and Magana met in Costa Rica.

Magana, 57, comes for what was described as "an official working visit" after a series of shake-ups in Reagan's Central American team, including the announcement that the U.S. ambassador to El Salvador, Deane R. Hinton, is being replaced.

State Department officials said topics of discussion will include Magana's plans for presidential elections scheduled before the end of the year, as well as the issues surrounding White House certification that progress is being made in protecting human rights in El Salvador. Reagan must submit such certification to Congress by July 22 in order for El Salvador to continue receiving U.S. military aid.

Meanwhile, the Pentagon said yesterday that two U.S. advisers in El Salvador "violated the guidelines" on staying out of danger. A Pentagon spokesman who asked not to be identified said he believed the men, who were not identified, had been reprimanded.

The Pentagon statement, issued in response to inquiries, was vaguely worded and did not describe the violations.

Sources who asked to remain anonymous said the incident occurred on the same day in February that Staff Sgt. Jay T. Stanley of Towson, Md., was wounded in the leg when the helicopter he was in swooped close to a column of rebels.

Under U.S. policy, American advisers and trainers are to remain out of any area where they might come under fire.

Defense officials said the investigation involving Stanley led to the discovery of the alleged violations by the two advisers in what were described as "unrelated circumstances."

Rep. Michael D. Barnes (D-Md.), meanwhile, charged that the government of Nicaragua has sponsored "absolutely inexcusable" anti-Semitic acts and propaganda that forced the country's entire 50-member Jewish community to leave three years ago.

Barnes, chairman of the subcommittee on the Western Hemisphere, wrote Nicaraguan junta head Daniel Ortega that the acts, as described by the Anti-Defamation League of B'nai B'rith, put Nicaragua "on the same level as Argentina with respect to human rights."

Rabbi Morton M. Rosenthal, head of the league's Latin American Affairs Department, said that Abraham Gorn, leader of Nicaragua's Jewish community, was jailed in 1979 and his property confiscated on charges that he supported ousted Nicaraguan dictator Anastasio Somoza. Gorn has denied the charges.

The community synagogue was taken over and assigned to the Association of Sandinist Children as a social club, Rosenthal said, while other community members were pressured to leave the country.

A spokesman for the Nicaraguan Embassy rejected the charges, and said that Nicaragua's ambassador will meet with Rosenthal Monday.

The spokesman also said Gorn and his son "had a well-known history" as Somoza supporters. She added that three Nicaraguan Cabinet ministers are Jewish.