Lewis M. Costello is a Virginia politician whose second biggest problem is that a lot of people mistake him for the late comedian.

His biggest problem is that he's a Democrat. And in Virginia's 7th Congressional District, one of the most solidly pro-Reagan districts in one of the most conservative states in the country, he couldn't ask for a much greater challenge this fall.

The 7th District, where incumbent Republican Rep. J. Kenneth Robinson is retiring after 14 years in Congress, includes parts of Prince William and Stafford counties and stretches south to the Richmond suburbs, west to Charlottesville and north to Winchester. And Winchester, where Costello lives, is also the home of the Byrds, the conservative first family of Virginia.

A tax attorney and a fiscal conservative, Costello, 50, is attempting to stake out a position as a man of the right in his race against Republican D. French Slaughter Jr., a former state legislator from Culpeper. Costello backs a constitutional amendment to balance the federal budget, and he pledges to support the president when he thinks he's right.

Nonetheless, Costello campaign manager Tom Vandever says "as long as he's just [identified as] the Democrat running for Congress, he's going to lose. We don't want to hide from being a Democrat, we want to augment that."

Slaughter has wrapped himself in a GOP cloak, trumpeting that a vote for him is a vote for Reagan, and hoping to ride the president's coattails into Congress.

He says that as a congressman he would differ with Reagan from time to time, but cannot think of any issues on which he disagrees with the president.

At the same time, Slaughter, 59, a Byrd Democrat who abandoned the party at the time of Sen. George McGovern's disastrous 1972 presidential bid, is busy trying to tie Costello to Democratic presidential candidate Walter Mondale, Virginia Democratic senatorial candidate Edythe C. Harrison and the ultimate bogeyman in the district, House Speaker Thomas P. (Tip) O'Neill.

Costello acknowledges that he supports Mondale. Slaughter provides the amplification.

"If you're there with the liberal leadership on that side of aisle," Slaughter says, "you've got no choice but to vote with Tip O'Neill. I'm supporting President Reagan and my opponent is voting for Mondale."

The candidates are similar on fiscal issues -- both oppose a tax increase and favor a balanced budget amendment -- but split on social issues. Costello favors the Equal Rights Amendment, which Slaughter opposes; Slaughter favors legislation to permit voluntary prayer in public schools, which Costello opposes. On military issues they are also close, although Costello has called for a mutual and verifiable freeze in the nuclear arms race, a stand that Slaughter opposes.

The Republicans say Costello isn't a conservative. "If you look at what [Costello] says," said Slaughter campaign manager Dennis Peterson, "you'll see he's not a conservative at all . . . . He's a national Democrat who's on the Mondale-O'Neill team."

Strategists for both candidates say the campaign is already by far the most expensive ever in the district. Slaughter, who faced a tough nominating fight against former Fairfax legislator Guy O. Farley has raised more than $200,000. Slaughter has paid off about half of a $50,000 line of credit extended to him during the primary by Second National Bank of Culpeper, on whose board of directors he sits. Costello has tried to make a campaign issue of the Slaughter campaign debt, saying that it belies Slaughter's claims of fiscal austerity.

Slaughter has already sent out a district-wide mailing and launched radio advertising spots stressing his 20 years in the General Assembly, his sponsorship of state legislation creating the Virginia community college system, and the endorsement of Republican incumbent Robinson.

Costello is planning, Vandever says, a campaign budget of at least $200,000. With $90,000 raised so far, and a powerful fund-raising drive in the works, it's possible the Costello forces will exceed that goal.

Costello's most important ally and possible trump card in the campaign is Del. Alson H. Smith Jr. (D-Winchester) a popular legislator renowned for his fund-raising abilities. Smith and Costello have known each other for 20 years, but their friendship was cemented in 1973, when Costello bowed out of a contest for the Democratic nomination for delegate from Winchester, clearing the way for Smith. Half of the $90,000 raised by Costello came in a $1,000-a-couple fund-raising roast for Gov. Charles S. Robb that Smith arranged.

A Costello poll taken in June showed Slaughter with a slim lead. Twenty-seven percent of those surveyed said they favored Slaughter; 22 percent backed Costello. Both candidates had low name recognition.

The poll may have masked Costello's larger party problem. The district voted for Republican J. Marshall Coleman over Robb in the 1981 gubernatorial elections, and officials in both parties say they expect Republican Sen. John W. Warner to trounce Democratic challenger Harrison this fall, riding the Reagan wave.