Changes in federal tax law have resulted in billions of dollars in unexpected revenue for state governments across the country, and officials in Maryland and Virginia are estimating a $100 million surplus in each state.

Officials in the two states and the District say there was an end-of-the year rush by taxpayers in 1986 to sell stocks, bonds and other property and beat changes in federal tax law that increased the tax on capital gains.

The result is increases in income taxes that are expected to reap between $10 billion and $15 billion for the federal government and billions for state and local governments.

However, the money is not likely to solve long-term problems. George H. Spriggs Jr., director of the income tax division of the Maryland comptroller's office, warned that the money was a one-shot proposition at best.

He said he is concerned that the sales would have taken place anyway and that the money could be considered more of an advance than a windfall.

"These {properties} would have been sold sometime in the future," he said.

Maryland officials say it is unlikely that they will try to return the money to taxpayers because it amounts to tax revenue the state would have reaped anyway at later dates.

Spriggs said the $100 million figure for Maryland is just an estimate.

"We really can't be sure until we close the books in August," Spriggs said.

But that has not stopped Maryland legislators from looking for ways to spend the money. The most popular idea is to use it to speed the repayment plan to savings and loan depositors whose funds have been frozen for two years.

State officials have pledged to repay the depositors by 1989 by selling the assets of Old Court and First Maryland savings and loans and by adding a contribution from state taxpayers.

Gov. William Donald Schaefer said last week that it was too early to say exactly how the state should spend the surplus tax money. "First of all, we haven't even gotten this year's budget into operation," he said.

"If you all will just give me a day or so, maybe a week, to figure out the state of finances, I appreciate it."

But Schaefer indicated that not all of the money would go the savings and loan fund, saying that the plan to add up to $50 million to the reserve in each of the next two years would be sufficient for the state's payback plan.

Maryland Senate President Thomas V. Mike Miller Jr. (D-Prince George's) said he thought that at least a third of the money would be placed in a "rainy day" fund.

He said the rest should be divided between the savings and loan fund and improvements in higher education, which is likely to be a major issue for the General Assembly next year.

District officials said they were uncertain how much of an increase they would receive, and Virginia officials were cautiously predicting a $100 million gain.

"We're reluctant to even make a stab at this before the end of June," when the state expects its annual surge in estimated-tax payments from self-employed people, said Karen F. Washabau, Virginia's deputy secretary of finance.

Washabau said that revenue to the state from individual taxpayers is growing at a rate of 15 percent beyond 1985 levels -- and well above the 8 percent growth the state was predicting last year.

The 8 percent annual growth translates into $2.3 billion for the state treasury, a total it has nearly reached today, a month before the end of the Virginia government's fiscal year.

Washabau said that the revenue picture is clouded by uncertainty over the final total of state tax refunds, which are running several weeks late this year.

New sources of revenue are coveted by all state governments, but the administration of Gov. Gerald L. Baliles is particularly eager for additional funds.

Baliles recently began preparing the state's biennial budget for 1988-90, and he would like to embark on a series of initiatives that almost certainly would require additional money.

Last fall, Baliles persuaded the General Assembly to raise some state taxes to pay for a massive transportation construction program.