The U.S. economy turned in one of its best post-World War II performances last year, with a strong expansion accompanied by low inflation, the Commerce Department reported yesterday.

The department said the nation's gross national product -- the measure of output in goods and services -- grew 6.8 percent while inflation, as measured by changes in prices and type of output, was put at 3.7 percent, compared with 3.8 percent in 1983 and 6.0 percent in 1982.

The GNP increase was the sharpest since 1951, and the inflation rate was the best since 1967, the department said.

The report also indicated to analysts that the economy is pulling out of its mid-year slump and will be stronger than expected in 1985, with continued moderate inflation.

"If this were almost any other country in the world, the economic performance of the United States would be termed a miracle," said White House spokesman Larry Speakes. "Indeed, it has been impressive."

However, Commerce Secretary Malcolm Baldrige warned that if the government makes only small inroads in reducing the federal budget deficit, it could jeopardize a promising economic picture.

"To reinforce the staying power of this expansion in the years ahead, our first priority must be a reduction in the federal deficit to help hold down inflation and bring down interest rates further," Baldrige told reporters.

The Reagan administration is counting on growth of at least 4 percent this year, providing enough employment to help reduce the federal budget deficit by restraining outlays and producing higher tax revenues.

Some economists doubt that the administration will get its wish and are predicting growth of slightly more than 3 percent.

However, Baldrige told reporters yesterday, "With lower interest rates and inflation under control, the economy is in a good position to achieve the 4 percent growth expected by the administration over the course of 1985."

Baldrige said he expected strong growth in the first half of the year, which may taper off after the summer, depending on whether significant budget reductions are made and the fate of the tax simplification drive. A reduction in the fiscal 1986 budget deficit of $50 billion -- the amount sought by the administration -- is vital to help interest rates decline, Baldrige said.

In the fourth quarter of 1984, GNP increased at a 3.9 percent rate, following 1.6 percent growth in the third quarter. Last month, Commerce estimated that output in the last three months of the year had increased at a 2.8 percent rate.

Inflation, measured by the implicit price deflator, rose 2.4 percent in the fourth quarter, compared with 3.9 percent in the third quarter. The implicit price deflator measures changes in prices and the composition of output.

Economic activity last year ran the gamut from frantic spending and rising interest rates to almost no growth and falling interest rates. Frenetic buying by consumers and businesses pushed GNP growth up 10.1 percent in the first quarter and 7.1 percent in the second quarter.

However, domestic spending dropped off sharply in the summer, blamed in part on high interest rates and increasing purchases of imports. In addition, some economists said that consumers had satisfied their pent-up demand for goods and that their proportion of debt to disposable income was reaching record highs, causing them to spend less.

A strike at General Motors of Canada Ltd. reduced the amount of parts available for U.S. automobile production, further restraining output. As consumer and business demand dried up, interest rates began to fall, and recession fears were rampant. The Federal Reserve Board decided to lighten its grip on the money supply and allow interest rates to fall further to stave off a recession.

Since August, interest rates have declined -- the prime interest rate has dropped from 13 percent to 10.5 percent -- providing encouragement for increased spending on capital goods, automobiles and housing. Continuing employment growth, increases in personal income and other recent government statistics point to a modest rebound in the next few months.

The 6.8 percent increase in GNP last year was the sharpest since an 8.3 percent rise in 1951, the Commerce Department said. GNP rose 3.7 percent in 1983 and dropped 2.1 percent in 1982.

Economists yesterday noted trends in the fourth-quarter figures that seemed to foreshadow stronger than expected growth in 1985. Final sales, which declined during the third quarter, increased 8.3 percent during the final three months and offset a decline in inventory investment. Personal consumption expenditures rose $10.3 billion, compared with $1.7 billion in the third quarter, although business fixed investment rose $5.6 billion, compared with $6.6 billion in the third quarter.

The trade picture also improved in the fourth quarter, for the first time in three years, Baldrige said. The trade position improved by $11.8 billion in the fourth quarter after an extraordinary slump of $15.6 billion in the third quarter. Although total exports decreased $1.2 billion, total imports declined $13 billion, compared with an increase of $18.2 billion in the third quarter.

For the year, real gross national product increased $104.3 billion to $1.639 trillion, compared with $1.534 trillion in 1983. Unadjusted for inflation, gross national product in 1984 was $3.661 trillion, compared with $3.304 trillion in 1984.