The Virginia Senate yesterday easily approved a bill prohibiting cities and counties from enacting laws requiring deposits on beverage containers but agreed to an amendment that will allow Fairfax and Loudoun counties to retain existing ordinances if they withstand all court challenges.

The bill passed, 26 to 10, and now goes back to the House of Delegates for its action on the Fairfax-Loudoun amendment. Del. Thomas W. Moss (D-Norfolk), sponsor of the legislation, said he expects the House to agree to the Senate change today, the final day of the General Assembly session that began on Jan. 11.

Northern Virginia senators made a vain effort to exempt other cities and counties in the Washington suburbs from the prohibition.

Sens. Charles L. Waddell (D-Loudoun) and Joseph V. Gartlan (D-Fairfax) argued that Northern Virginia constitutes a separate trading area that would provide a good test of the effectiveness of deposit laws as a means of controlling litter.

A Waddell amendment that would have extended the exemption throughout Northern Virginia failed, 22 to 15.

Supporters of the bill preempting local ordinances argued that soft drink distributors should not be subjected to a "patchwork" of deposit laws enacted by scattered cities and counties.

They contended that the present Virginia antilitter law, which combines an advertising program with penalties for litter violations, should be given a chance to succeed before a statewide deposit law is considered.

Gartlan says he sees no difference between a statewide law and one encompassing a metropolitan area. "The debate on this subject is getting down to what is the size of a patch," he said. "If we leave it to the states to enact deposit laws, we still will have a patchwork policy throughout the country. Patchwodk at the local level is no worse than patchwodk at the state level."

The Fairfax Loudoun ordinances have been in effect for one year. They are being challenged in state courts in each county. Supporters of the amendment exempting the two counties from having their ordinances preempted cited a General Assembly convention of avoiding legislation that would affect pending court cases.

The House approved by a wide margin several amendments to the parimutuel betting bill passed by the Senate yesterday, which clears the way for Gov. John N. Dalton to sign the bill. The measure, a subject of controversy for nearly a decade, would permit the possible establishment of racetracks in Virginia if a statewide referendum on the issue next fall is successful.

The amendments prohibit members of the General Assembly or their law partners from serving as counsel to the racing commission that will be appointed to control the privately owned racing tracks. Another amendment prohibits members of the General Assembly and the governor's cabinet from owning stock in a racetrack, and places the records of the racing commission under the Freedom of Information Act.

In other action, the House agreed to Senate amendments to a bill that will allow optometrists to use certain drugs to examine eyes that only ophthalmologists are now allowed to use. Ophthalmologists are medical doctors and their protests against the bill made it one of the more controversial issues of the session.

In other House action yesterday, the delegates defeated, 55 to 38, a controversial bill sponsored by Sen. Charles J. Colgan (D-Prince William) that would have allowed cities and counties to combine into electrical authorities for the purpose of building power plants.

Existing state law permits individual cities and counties to generate and sell electricity but does not allow joint ventures by groups of more than one local government.

The bill was defeated by an unusual coalition of consumer advocates and opponents of government operation of traditionally private enterprises. The arguments of both reflected an uneasiness in the assembly over the establishment of governmental bodies not directly responsible to voters.

Even the passage of amendments that would have subjected the government-run utilities to regulation by the State Corporation Commission did not satisfy opponents of the bill. In the end, some delegates representign cities and counties that wanted the new authority voted against the bill because they felt the amendments were too restrictive.

Del. Warren G. Stambaugh (D-Arlington) told the delegates he opposed the bill, partly because of apparent public dissatisfaction with the operations of the Fairfax Water AUthority.

Del. David G. Brickley (D-Prince William) argued that the nonprofit government authorities would offer the prospect of lower utility rates. However, Del. Ralph L. (Bill) Axsell (D-Henrico) complained that residents of his county served by a government-owned gas utility "pay rates as high as any in the state."

The Virginia Electric and Power Co., the state's largest utility, did not oppose the bill, apparently because it views government authority as a possible source of capital to finance future joint public-private generating plants. However, the Appalachain Power Co., which serves western Virginia, strongly opposed the measure.

Virgina Lt. Gov. Charles S. Robb yesterday cast his first tie-breaking vote as presiding officer of the state senate. By breaking a 17-to-17 tie with a yes vote, Robb gave approval to a bill that would exempt restaurants with small dance floors from local dance hall regulations.