The U.S. Supreme Court let stand yesterday a lower court ruling invalidating a District of Columbia tax on the incomes of doctors, lawyers, accountants and other professionals.That will force the city to refund an estimated $40 million it had already collected.

The high court denied without comment a petition filed by the financially strapped city asking the justices to hear an appeal of a Feb. 12 D.C. Court of Appeals decision that struck down the tax.

City officials could not say yesterday when or how the money would be refunded, but City Administrator Elijah B. Rogers said work would begin on a repayment plan.

Professionals associated with about 4,500 city firms will be entitled to the refunds. However, about one-third of the professionals who paid the tax live in the District, and it is likely they will not benefit much by a refund. lIn fact, they may actually owe the city more money in personal income taxes.

For a $50,000-a-year suburban lawyer or other professional who has paid the tax annually since it was imposed in 1975, the refund could total $7,500.

Mayor Marion Barry had no official comment on the court's decision. His press office referred inquires to City Administrator Rogers and D.C. Corporation Counsel Judith W. Rogers.

James L. Lyons, one of the attorneys for the professionals, said he would expect the District to refund the money "as soon as it is practicable."

"We are sensitive to the city's financial situation," Lyons said, referring to the fact that the city already faces a budget deficit of at least $170 million this year.

"At the same time," Lyons said, "the courts have emphatically ruled that the tax is illegal, and we believe it should be refunded promptly."

The tax was imposed five years ago on the incomes of all professionals who conduct business in the city, even if they lived in suburban jurisdictions. wBut the D.C. Court of Appeals ruled that the levy amounted to a commuter tax, something that is specifically forbidden by the city's home rule charter.

Ed Meyers, deputy director of the city's Department of Finance and Revenue, said the 4,500 firms involved multipartnered operations to one-man offices. The tax was actually levied on the business, not the professionals themselves, so Meyer said his agency could not say precisely how many individuals are affected.

Meyers said a total of $56.8 million was collected under the illegal tax, but the city will only have to refund $40.4 million -- including interest -- because nearly $20 million will be recaptured from prfessionals who live in the District and now will have to pay more city income tax.

In fact, Meyers said, some high-incime D.C. professionals will actually owe the District government money -- a situation resulting from the fact that the tax was skewed to have less impact on city residents than suburbanities.

Only 30 percent of a professional's income was subject to the tax -- at a rate of 9.9 percent. The remaining 70 percent for professionals who were District residents was subject to D.C. personal income taxes, which range up to 11 percent for high-income persons.

Meyers said the city will now collect personal income tax on that 30 percent formerly subject to the professionals' tax. So some high-income professionals who both live and work in the city will find themselves owing the District 11 percent on some income while the District owes them just 9.9 percent on the refund -- a net loss.

Professionals who conduct business in the city but live in the suburbs will in all likelihood reap a benefit from the court decision, Lyons said.

The reason is that while D.C. residents were allowed to forgo personal income tax on the 30 percent of income subject to the illegal professionals' tax, suburbanites had to pay income taxes in their states and cities on their entire net income, with deductions allowed only for money actually paid into the D.C. treasury under the professionals levy.

Judith Rogers said she would recommend to Barry that the city ask Congress to "clarify" the home rule charter to allow such taxation.

"The city has to be able to tax legitimate sources of income within its borders," she said. "I think it will be important to the future of this city to be able to tax these revenues."

Elijah Rogers said the funds that have to be repaid already have been included in the city's $284-million budget deficit accumulated over the last 10 years and disclosed by Barry last week.

However, Elijah Rogers said the city has not yet assessed how the man-dated refund fits into the District's bleak financial picture. "We don't know yet if we have to repay the tax this fiscal year or not," he said.

Barry has said previously that if the city has to repay the tax this fiscal year, ending Sept. 30, he will try to borrow funds the U.S. Treasury to cover the refunds.

There were other unanswered questions as well.

It was unclear whether professionals who are due a refund would be sent a check automatically or whether they would have no file for one. It was also uncertain whether actual checks would be sent at all to professionals who live in the District since some of them will actually owe the city money.

City officials said these questions are still being analyzed, even though the tax was first struck down by a three-judge appeals court panel in April 1979, more than a year ago.