U.S. District Judge Oliver Gasch of Washington, in an admitted violation of a judicial canon, contributed $500 to the campaign of Virginia Republican Senate nominee John W. Warner.

The donation from Gasch, identified by a Warner spokesman as a "personal friend" of the candidate, was disclosed yesterday in a campaign finance report that showed Warner spending 60 percent more money than his Democratic opponent, Andrew P. Miller.

Interviewed late yesterday, the judge said he had not realized he was in violation of judicial ethics by making the donation. "Well, I know it now," said the 72-year-old judge, who was named to the federal bench in 1965 by President Lyndon Johnson.

Canon 7 of the code of judicial conduct that governs federal judges prohibits all political activity by jurists, including contributions to candidates. There are no specific penalites for violation of the canons, but the Judicial Council of the U.S. Court of Appeals for the District of Columbia has the power to reprimand a District Court judge for any misconduct.

"Had I known it was a violation, I would not have made the contribution," Gasch said in a telephone interview. But he said he would not ask the Warner campaign to refund his donation. "I wouldn't if I could. I gave him the money," the judge said.

Disclosure of Gasch's donation shocked some Washington area court authorities. One official familiar with the administration of federal courts said he had never heard of a judge making a donation to a partisan political campaign.

Gasch said he wrote the $500 check to Warner while he was vacationing on Cape Cod in August after learning that Warner had received the GOP nomination following the death of Richard D. Obenshain. "I opened my checkbook and I wrote him a check," the judge said."That's all there was to it."

In Richmond, Warner campaign aides said they were unaware that judges were prohibited from making campaign donations and said the campaign would do "whatever the judge wishes" with his donation.

Gasch called Warner "a close friend . . . a very able man" and said their friendship dated from 1953 when Warner was a law clerk for District Judge Barrett Prettyman in Washington . A Warner spokesman said that Warner is a godfather to the judge's son, Michael.

Gasch, a former U.S. attorney in Washington, is considered a judical moderate.

He is described as fair in handing down sentences in criminal cases but was subjected to criticism when he sentence former Senate aide Bobby Baker to to one to three years in prison for his conviction on tax evasion and other charges.

Gasch presided at the trial of Rep. Charles C. Diggs Jr. (d-Mich.), who was convicted Saturday of mail fraud and charges that he illegally diverted more than $60,000 in pay to his congressional staff for his personal use.

The Gasch contribution was disclosed in reports showing that Warner had expenditure and unpaid obligations of $415.642 for the period ending Sept. 30, to $261.405 for Miller.

The two candidates are not far apart in money raised from contributors - $223,666 for Miller and $209.135 for Warner - but Warner has borrowed $125,000 for his campaign, raising total receipts to more than $334,000.

All of Warner's fund-raising reported yesterday was achieved in the first six weeks after he became the nominee. Miller's report covers a three-month period beginning July 1.

Although Warner has borrowed $125,000 for this campaign months after spending more than $400,000 of his own money is an unsuccessful convention contest for the nomination, his report shows he has had remarkable fund-raising success, especially among relatively small contributors.

The Miller report, on the other hand, shows a heavy reliance on large contributions from both individuals and from business and labor union political action committees.

Warner has raised more than $94,000 from givers of less than $100, about $67,000 from contributors of more than $100 and about $48,000 from political action committees. He has received only 31 contributions of $1,000, the maximum amount that an individual may give.

Miller has raised more than $119,000 from contributors of more than $100 - including 58 gifts of $1,000 - and about $60,000 from political action committees. Only a little more than $40,000 of his money has come from contributions of less than $1,000.

Warner's disclosure of expenditures revealed a heavy investment - almost $114,000 - in a direct mail campaign targeted to appeal to various voter interest groups. Such direct mail efforts proved effective for Republican Gov. John N. Dalton last year, both in delivering hard-hitting campaign pitches and in raising small contributions.

Separately, the two Northern Virginia Republican congressional candidates filed reports showing that they are outspending the Democratic incumbents they are challenging in the November elections.

In the 8th Congressional District, Republican challenger John F. Herrity, chairman of the Fairfax County Board of Supervisors, has raised $126,343 and spent $122,702, while Democratic incumbent Herbert E. Harris II has collected $100,000 and spent $86,000. In the period from July 1 to Sept. 30 Herrity outspent Harris nearly four to one.

Republican Frank Wolf has raised one-and-a-half times more money in his race than has Democratic Rep. Joseph L. Fisher, according to the finance reports. Wolf's contributions totaled $163,873, including an $11,000 personal loan and $76,000 from business and conservative political groups.

Fisher, a two-term incumbent, reported $96,839 in donations, with most of the money coming from individuals. Business and labor groups donated $10,045 to his campaign, the reports said.

The report showed Wolf had spent $120,495 on his race compared to $58,690 by Fisher.