Maj. Gen. Robert L. Schweitzer, the top military officer on the National Security Council staff, was relieved of his White House duties yesterday and sent back to the Army after giving a hard-line speech about Soviet military intentions that administration officials said was unauthorized and "at some degree of variance" with the president's views.

Richard V. Allen, chief of the NSC staff, told reporters he was relieving Schweitzer with "great regret" but the general had broken a rule that all public remarks by staff members have to be cleared by Allen in advance.

Schweitzer, a highly decorated officer, made his remarks in a speech and question-and-answer session Monday before an audience of hundreds of Army officers and others at the convention here of the Association of the United States Army.

The meeting was open to the press, and the association had put out press releases advertising the panel discussion on "a global strategic appraisal for the '80s" in which Schweitzer took part. An account of his remarks appeared in The Washington Post yesterday.

Allen said that he made up his mind to relieve the general after reading that account yesterday morning. President Reagan concurred in the decision and said later in the day that he did not agree with what the general had said. But he referred to Schweitzer as "a fine soldier" whose services will continue to be "of great benefit to the country" in another post.

The White House said Rear Adm. James Nance of the NSC staff would replace Schweitzer.

In his remarks, Schweitzer claimed that Moscow now has nuclear superiority over the United States in all three legs of the strategic triad of land-based and submarine-based missiles and bombers, an assessment that is not accepted by the administration. He spoke of a "drift toward war" and said the "Soviets are on the move; they are going to strike." The United States, he claimed, is "in the greatest danger that the republic has ever faced since its founding days."

Apparently speaking without any prepared text, Schweitzer also said that evidence continues to mount that the Soviets have in mind an invasion of Poland and that Moscow regularly practices military exercises aimed at taking over Persian Gulf oil fields. He said some church leaders in this country are not helpful in combating the Soviet presence in Latin America and warned of a backlash involving Israel if Congress thwarts the proposed sale of AWACS planes to Saudi Arabia.

Presidential spokesman David R. Gergen told reporters early yesterday that Schweitzer "was expressing a personal point of view which is at some degree of variance with the president's." Gergen said Schweitzer's remarks were "more pessimistic in tone and substance" than Reagan's own position on the Soviet posture. The president, asked during a brief photo session yesterday if he agreed that there was a drift toward war, said "no" and added that he was following policies--apparently a reference to his proposed military buildup--"so there can't be a drift toward war."

Allen said yesterday that he had not heard Schweitzer express his stated views before and said the general was sorry about both the speech and its content. Allen said the general, when asked for an explanation, said, "I went further than I meant to." Allen said it is very important that the discipline of the NSC staff be maintained and that all public remarks by senior aides be assessed internally in advance because they will be construed as policy statements.

Allen has kept the council staff under tight wraps, allowing virtually no public statements other than his own, and no contact with reporters. Last March, an NSC official later identified as Richard Pipes, a Soviet expert, gave an interview to the Reuters news service in which he also took a hard-line stand and which also caused a big flap. Pipes was quoted as saying that "detente is dead" and that Moscow is bent on a worldwide "imperial drive." Pipes did not lose his job, however.

Such views are not much different from some of the things the administration has said publicly, but the administration wants maximum control over what is said and who says it. Yesterday, Sen. Alan Cranston (D-Calif.) said he was "appalled" by Schweitzer's "irresponsible statements," adding that "such war talk bears the danger of becoming a self-fulfilling prophesy when mouthed carelessly by top presidential assistants."

Schweitzer, 53, who was deputy commander of a cavalry regiment in Vietnam and holds the Distinguished Service Cross and seven Purple Hearts for wounds in battle, appeared almost fatalistic while giving the speech about the possibility he would get in trouble for it.

"I would hope that the one thing I learned as a staff officer . . . was to avoid the minefields of joining the foot-in-the-mouth club. To get up here speaking for the White House, as inevitably I am doing, and lay out a major foreign policy . . . before the president of the United States has done it, is a little bit too sporting for me."

Perhaps jokingly, Schweitzer added, "I very much feel I'm malassigned in the job I'm in" and said he hoped to be able to spend some time with the Army's leadership "to get me assigned to a soldierly job." Schweitzer quickly added that he didn't want to do that by making headlines and preempting the president, but that is exactly what happened.

At another point, he told the audience he hadn't cleared any text with the White House and also joked that "the last time I had any contact with the political area I was head of 'Army Colonels for McGovern at Harvard,' the smallest political constituency on the face of the Earth. I would have thought" that background, a reference to the former Democratic senator George McGovern, "would have suggested this administration would rather have me out with the divisions somewhere."

There were also some hints yesterday from White House aides that another defense specialist, William Van Cleave, may be in trouble for being too outspoken. Van Cleave served as a top defense adviser during the Reagan transition period but was vetoed for a top Pentagon job after the inauguration. He has recently been named, however, as chairman of the general advisory committee on arms control, a post subject to Senate confirmation.

In an interview with Reuters last week, Van Cleave sharply criticized the administration's decision to deploy MX missiles in improved versions of old Titan missile silos.

He said such a deployment invited a first strike by Moscow and conflicted with the Republican platform because it left U.S. missiles vulnerable and thus did not close the so-called "window of vulnerability." He said the MX vulnerability would decrease stability in a crisis and could also push the United States to a "launch-on-warning" policy, which means firing U.S. missiles before they can be destroyed.

Van Cleave told Reuters that "this is a very, very serious matter" and that he felt it was important to speak out.