Virginia Gov. Charles S. Robb and other state Democratic leaders, assessing the beating their party took Tuesday, looked to the future today and found themselves recalling 1981.

That was the magic year the Democrats bounced back from their first thrashing by Ronald Reagan and went on to win the governorship for the first time in 16 years and to pickup both the state offices of lieutenant governor and attorney general as well. Robb and his fellow Democrats know that's the challenge they will face again in next fall's state elections.

It was brave talk, according to some party members who insisted Democrats may need some magic after a GOP sweep Tuesday that some fear will spill into 1985. "We got the hell beat out of us," one Democrat said of Tuesday's results.

Republican Sen. John W. Warner trounced Democrat Edythe C. Harrison by 70 percent to 30 percent while President Reagan, who always was expected to carry Virginia, defeated Walter F. Mondale by a lopsided 63 percent to 37 percent.

The memories of 1981 gave solace and hope to Democrats who also rejoiced that they did not lose any incumbent Democrats in the 10-member House delegation that remained divided 6-to-4 in favor of the Republicans. All nine incumbents won reelection.

But the loss of Lewis J. Costello, the Democratic challenger for the open seat in the 7th Congressional District was more troublesome than party leaders wanted to admit, according to Democratic party insiders. "Costello was Robb's" candidate, one said.

The governor sent out letters supporting Costello and officials believed he had a chance to defeat Republican D. French Slaughter Jr. of Culpeper, who will replace retiring Republican Rep. J. Kenneth Robinson of Winchester.

Warner, who led Harrison, a 50-year-old former state legislator in every section of the state, scored heavily against her in all income, age and education levels among voters and ran well ahead of Reagan. Warner even defeated Harrison in her home town of Norfolk, a Democratic stronghold that Mondale carried.

Virginia has voted Democratic in presidential elections only once since 1948: in 1964 when Robb's father-in-law, Lyndon Johnson, defeated Barry Goldwater.

Robb, an extremely popular governor whom some party members fault for not finding a stronger Democratic Senate candidate, said at a news conference today that Harrison's race had been virtually "unwinable" from the start.

"Politics is the art of the possible," Robb said. He noted that other potential candidates were turned off by Warner's strong position as a well-financed incumbent running with a president popular in Virginia.

The governor also confirmed previous reports that he had never considered Harrison a strong candidate and had faulted her for a campaign that was disorganized and prevented him from helping more.

Still, the governor went out of his way to praise Harrison's "courageous" campaign and said he had come to respect her more in the closing weeks of the campaign for her grasp of issues. "She has every reason to be proud," said Robb, noting Harrison was the first woman to run for a statewide office with major party backing.

But "there wasn't a single soul" in the party's leadership who believed Harrison would win, the governor said.

Robb strongly implied that he was not completely dissatisfied with Warner's performance as the state's senior senator. He declined to say anything negative about him, a similar stance that he took during the campaign.

Despite the Democrats' concerns, leading Republicans were cautious about what effect Tuesday's election will have next fall. "It doesn't mean a thing for the party in 1985," said John Alderson, a Roanoke insurance man who served as the Reagan-Bush state coordinator and is considering a bid for lieutenant governor. "We have to start from ground zero."

The Republicans easily outspent the Democrats this fall and signed up thousands of new voters and volunteers who could have an impact next year.

"It's certainly not time to wave our hand and surrender the ship," said a supporter of Attorney General Gerald L. Baliles, who is seeking the Democratic nomination for governor. "But it is time for the hard analytical look at voting in each area of the state . . . . "

In a mirror of the problems the national Democratic Party faces, state Democrats said privately they must reconcile the influence of blacks, who overwhelming have tended to vote Democratic, with moderates and conservatives.