The Pentagon has gained a "secret dividend" of $18 billion to $50 billion over the past four years because of the Reagan administration's "unexpected success . . . in lowering inflation," Rep. Les Aspin (D-Wis.), chairman of the House Armed Services Committee, said yesterday.

Aspin said Congress appropriated more money than was needed from 1981 to 1985 because the Pentagon's inflation projections were too high. And he said he wants to know what happened to the money.

"I am not suggesting there has been any wrongdoing on the part of the Pentagon," Aspin said. But he did accuse the Defense Department of setting inflation projections too high.

He also charged that extra inflation funds that went to defense contractors "logically show up as higher profits." He noted that since 1981, profit margins of all but one of the top 10 defense contractors had risen and in 1984 six of those 10 were at their highest level in 15 years.

The Pentagon's two top officials were quick to respond to Aspin's statement.

Defense Secretary Caspar W. Weinberger said yesterday that "the real news" is that the Pentagon was "able to get more in defense than Congress thought we could." He added, during an interview on NBC-TV's "Meet the Press," that "good management . . . , increased competition and . . . a lot better defense for the price" had resulted in savings.

Deputy Defense Secretary William H. Taft IV, in a statement, said the department had "regularly reported" to Congress on the surplus from lower-than-expected inflation rates.

Aspin, however, charged that the Pentagon's inflation-rate factor was set 30 percent higher than the rest of the government and that this, along with projections of higher unit cost for major weapons procurement, had given the Pentagon almost $5 billion more per year than it needed.

He said that if inflation from fiscal 1982 through fiscal 1985 had been projected accurately, appropriations for Pentagon operations, research, military construction and small purchases could have been $18 billion lower.

Aspin said he also wanted to change the way those projections are incorporated into the defense budget.

He suggested that the inflation factor be determined at the end of the fiscal year rather than before it. He also said he had written Weinberger to ask the secretary to help "design a more rational and fair system . . . for coping with the inevitable problem of errors in inflation projections."