Defense Secretary Caspar W. Weinberger expressed confidence yesterday that the Pentagon could stay within President Reagan's budget, thanks in part to declining inflation.

His optimism, expressed in an interview with The Washington Post, contrasts with the gloom and doom of several other administration officials, who are warning that Pentagon bills are piling up so high that Reagan's plan to balance the federal budget by fiscal 1984 is in jeopardy.

An internal Pentagon budget stamped secret, for example, warns that the cost overrun in the fiscal 1983 budget now being put together will be about $6 million which would require a 9 percent increase adjusted for inflation over 1982 rather than the planned 7 percent.

Deputy Defense Secretary Frank C. Carlucci told The Post in a separate interview that the Pentagon's fiscal 1983 budget is running from $2 billion to $10 billion above projections.

Weinberger, sitting at a round table of the side of the massive desk that comes with the job, a desk originially used by World War I. Gen. John J. (Black Jack) Pershing, chose to accentuate the positive, however.

"We believe that we can acquire what is needed within the guidance that has been given," said Weinberge, referring to the 7 percent annual real growth, "provided inflation doesn't erode some of the existing programs. And we don't see that it is at this moment.

"I personally have been very encouraged by the way inflation has been coming down," continued Weinberger, who was President Nixon's budget director. "I think when the president's economic program is fully in place, taxes and budget cuts, both of which are moving along nicely, that there will be a very good effect on the marketplace and we'll find a continuation of the decline in inflation. Part of it will depend on how firmly the Federal Reserve can keep hold of monetary policy."

In discussing how much is enough for defense with fellow administration executives, presumably including Reagan himself, Weinberger said he had contended that the Pentagon could make good use of more than a 7 percent real growth. However, no formal request for more has been lodged. "We have made no requests for anything beyond that," said Weinberger of the 7 percent annual increase. "We haven't said anything about needing more. We have pointed out that it is extremely important that we stay with that; that we not surge one year and starve the next; that we follow a steady, predictable path of growth in real strength."

In March, Weinberger predicted that to achieve a real growth of 7 percent annually the Pentagon budget figures would have to be: fiscal 1982, $222.2 billion; fiscal 1983, $254.8 billion; fiscal 1984, $289.2 billion; fiscal 1985, $326.5 billion; fiscal 1986, $367.5 billion.

Those figures are total obligational authority, meaning all the money the Pentagon has in a given year for its programs. Not all of it is spent in one year, however. That five-year total comes to $1.45 trillion, an amount that will have to go higher to keep achieving 7 percent real growth if inflation runs higher than projected.

Under that $1.46 trillion program, Reagan hopes to build a new bomber -- perhaps two different types at ones; deploy a new MX land missile; push the Navy toward a fleet of 600 ships; modernize the Army; add some 200,000 soldiers, sailors, airmen and Marines to the active duty force of 2.1 million; gear up the defense industry for emergency production; be ready to take on the Russians all around the world.

Trying to do all that and balance the federal budget at the same time will be impossible, according to some administration official's assessment of the Reagan-Weinberger blueprint for rearming America. The behind-the-scenes arguments over this are beginning to break out into the open.

While advocating a gigantic military buildup to combat the Soviets, Weinberger favors taking a hard line on East-West trade. He decried yesterday Bonn's plan to buy natural gas from a pipeline leading into West Germany from the Soviet Union.

"There wasn't anybody in the room," said Weinberger of a recent White House meeting on the pipeline, "who thought it would be a fine thing for the Soviets to build a pipeline. All the discussion was on how to persuade the Europeans that this was not a very good thing for their interests or our own interests. That was the given. I joined everybody else in the room in feeling that it would be very unfortunate thing for the West and the Free World for that pipeline to be built. A lot is going to depend on whether the German and French banks continue financing it."