The nation's commercial banks suffered their worst quarter in more than half a century after writing off billions of dollars in Third World loans as uncollectible, the government said yesterday.

The 13,937 banks insured by the Federal Deposit Insurance Corp. added $21.2 billion to reserves for bad loans in the second quarter of 1987, causing a $10.6 billion loss, the first reported since the Depression.

"It was clearly the worst quarter in the history of the industry since the FDIC began operating in 1934," FDIC Chairman L. William Seidman said.

The second-quarter loss more than wiped out a record first quarter net income of $5.3 billion, posted after banks added $4.1 billion to loan loss reserves. The net loss for the first six months was $5.3 billion.

Seidman said he expected bank performance would turn around in the second half of the year. He predicted net income for the full year would be between $4.5 billion and $6 billion.

"Because of the loss reserves taken now, we would expect some improvement in the second half," he said. "This quarter, hopefully, is the worst report we're likely to see."

The huge loss in the second quarter had been expected. Major banks -- including Citicorp, Chase Manhattan Corp., Security Pacific Corp. and BankAmerica Corp. -- had all announced in May that they were adding to reserves to cover Third World loans, particularly to Brazil,which is refusing to pay on its $23.6 billion debt.

Seidman said he believed the reserves were the banks' best estimate of future loss, but some analysts say they should be even higher.

"I think we're going to see some more horrendous quarters in the next year or so," said Paul Getman, senior financial analyst with Wharton Econometrics, a Philadelphia forecasting firm.

The selling price on the market for the loans indicates they are worth far less than the value listed on the banks' books, even with the writedowns, he said.

"If interest rates continue to rise, these loans are going to be worth even less," he said.

Seidman said the loss for the second quarter was a little higher than he had expected. He said he believed banks set aside reserves for a broad range of loans in addition to foreign loans.

"This is kind of a variation of the big bath theory," said Bert Ely, a private financial industry analyst in Alexandria. "What they decide is that if you're going to take a hit, you might as well take it all at once and get it all behind you."

According to the FDIC's quarterly banking profile, 2,354, or 17 percent, of the nation's commercial banks were unprofitable for the three months ending June 30. That compares with 2,019, or 14 percent, in the first quarter.

Although 83 percent of the banks showed a second-quarter profit, the industry as a whole was dragged down by the 10 largest banks, which all lost money and account for nearly a quarter of all the banks' assets.

Banks continue to fail at a post-Depression record rate. As of Monday, 126 banks had failed this year and 16 would have failed without assistance from the FDIC.

The agency said 144 banks failed last year. Seidman is predicting 200 failures by the end of 1987 and 150 in 1988.

Banks in the Southwest, hit hard by faltering energy prices, accounted for 40.4 percent of money-losing institutions, and banks west of the Mississippi River accounted for 77 percent.

Seidman said the health of Midwestern banks has been improving as the price of agricultural land has stabilized or risen slightly.

Despite the second-quarter industry losses and an expected post-Depression record of 200 bank failures this year, Seidman said he expected the FDIC insurance fund to about break even for the year.

The American Bankers Association cited the quarterly bank health report as evidence bolstering its argument that banks ought to be permitted to underwrite securities and offer a broader range of financial services.

"The ... banking industry depends on congressional action to free the banks to compete in today's marketplace," said Donald G. Oglivie, ABA executive vice president.

"We cannot thrive ... while we are shackled by 50-year-old laws which prevent us from meeting {our customers'} needs."