In an ironic ending to a week of financial crisis, the Commerce Department announced yesterday that the economy expanded powerfully in the third quarter of 1987, growing at an annual rate of 3.8 percent, after adjusting for inflation.

The growth in the nation's gross national product was driven by healthy increases in consumer spending and business investment, and held back only slightly by deterioration in the U.S. trade deficit.

In another piece of favorable economic news, the Labor Department said that consumer prices rose a scant 0.2 percent in September, down from a 0.5 percent rise in August. Falling energy prices were the principal reason for the decline.

But the economy represented by those indicators has been drastically altered since the growth and inflation measurements were taken.

Economists said yesterday it may take consumers years to recover their financial confidence after last week's stock market collapse, the largest in history. Many experts are cutting back their growth forecasts for the October-December period, anticipating that consumers will spend less -- reducing economic growth for the fourth quarter. Some are predicting expansion of no more than 1 percent.

"The world is different after the crash. It will never be the same again," said Maury Harris, chief economist for the brokerage firm of Paine Webber. "Stock owners are going to realize they are more vulnerable. It's like living in Los Angeles and having a big earthquake: You know it can happen again."

Donald Straszheim, president of Merrill Lynch Economics said: "There were roughly 50 million dinner-time conversations Monday night {after the market collapse} in which the conclusion was: The winter vacation is off. We will see that in the retail sales numbers and consumer spending in a hurry."

The GNP report had little apparent effect on the stock market, which closed virtually unchanged from the previous day. And there were no apparent market repercussions from the announcement yesterday that plans for a U.S.-Soviet summit had suddenly been canceled.

The report on the consumer price index was seen as a positive sign, however, indicating that inflation is so low the Federal Reserve can safely pump more money into the economy to stabilize the battered stock market without reigniting inflation.

Commerce Undersecretary for Economic Affairs Robert Ortner said he expected the stock market crisis to have little impact on the real economy, which he said shows "healthy growth ... with no sign of accelerating inflation.

"In an economy that is sinking, it {the stock market} could have a noticeable effect," Ortner said. "But in an economy that is rising or strengthening ... it is my sentiment the effect is going to be small."

In his press conference Thursday evening, President Reagan said, "There are no ... signs of {a} deteriorating economy out there. ... "

There was one negative aspect of the GNP report. Net exports, the difference between exports and imports, declined for the first time in a year as imports of oil increased by $19.3 billion. The total import rise of $21.3 billion outweighed the increase in exports of $16.1 billion.

The economy grew by an inflation-adjusted 2.5 percent in the second quarter of 1987. The rapid expansion in the third quarter, the fastest increase since a 4.4 percent rate during the first three months of the year, was driven by a $29.5 billion increase in spending for personal consumption, particularly on autos in response to sales incentives. And the economy also benefited from a $23.9 billion increase in business spending on nonresidential investment.

Both rose more than $12 billion over the increases registered in the previous quarter, at annual rates. The rise in nonresidential business spending of 23.7 percent was the highest in more than three years. Consumer spending went up 4.8 percent.

The small increase in the consumer price index was principally due to falling energy prices and slight rises in shelter costs, the Bureau of Labor Statistics said. The energy component of the CPI fell 0.5 percent in September after rising 1.7 percent the previous month.

Food costs, on the other hand, went up 0.5 percent, and prices of apparel and upkeep rose 1.1 percent last month.

During the first nine months of 1987, consumer prices have risen at an annual rate of 4.8 percent, compared with a 1.1 percent rate of consumer-price inflation for all of 1986. Economists generally expect only gradual increases in prices, and experts speculated that interest rates could fall more -- they have declined sharply in the last few day -- as a result of the favorable inflation report.

"The CPI shows inflation deceleration," said Jerry Jasinowksi, chief economist of the National Association of Manufacturers. "This should put further downward pressure on interest rates."