Republican J. Marshall Coleman whirled through Northern Virginia yesterday, relishing his role of the underdog in the Virginia gubernatorial race and lacing his speeches and interviews with acerbic comments.

At shopping centers and Metro stops, an ebullient, wisecracking Coleman discussed polls, newspaper endorsements and the "vicious and personal campaign" of his Democrat opponent Charles S. Robb. Coleman predicted that Robb will be the underdog after the GOP plays its trump card tonight with the scheduled appearance of President Reagan in Richmond.

"The race is neck and neck, and the surge is going our way," Coleman told an interviewer at Springfield Mall in Fairfax County. The president is the most popular person in Virginia and his appearance . . . will energize our people."

Workers at the GOP headquarters in Richmond yesterday held an impromptu champagne party to celebrate the findings of a poll that for the first time showed Coleman ahead of Robb. Party spokesman Neal Cotiaux said a Richard Wirthlin poll of 200 persons Sunday night gave Coleman a two-point edge.

Cotiaux said the poll "took us by surprise" because just a week ago, Wirthlin's nightly telephone survey showed Coleman behind by eight points, about the same as the nine-point Robb lead reported Sunday by the Richmond Times-Dispatch.

"With the president coming in Tuesday, we have reached the 'era of good feeling,' " Cotiaux said. "For the next 24 hours, it's our show, and there is little the Democrats can do about it."

Republicans are still in the lead in another important category, that of raising money. Financial reports to be filed today are expected to show that Coleman has raised about $500,000 in the last three weeks, compared to $450,000 by Robb.

Each campaign already has topped $2 million in spending, buying broadcast commercials and delivering direct-mail letters in what is the most expensive political campaign in Virginia history. Coleman's spending may reach $3 million, including a final barrage for television and radio commercials that will feature Reagan's speech in Richmond.

At a nonpartisan forum at the BDM Corp. at Tysons Corner, where Robb will appear today, Coleman said he doubts that a GOP victory will be viewed as a referendum on the Reagan administration. "The Washington Post would make a lot more of it if I were to lose. But we won't know, because I'm going to win," he said.

In answer to a question prompted by a Post story about contributions he and Robb have received from special-interest groups, Coleman said: "I expect The Post to give me a week of good stories to make up for the past 31 bad weeks."

Coleman mentioned newspapers several times yesterday, pointedly discounting Robb's endorsement by The Post. Coleman said his supporters had conducted a poll which showed that "the only endorsements which make a difference are the Richmond newspapers." Both have endorsed him.

He attributed their influence to "the belief that they are the papers of record in Virginia, and they have observed us more."

Coleman spent nearly two hours yesterday morning at the Pentagon Metro station, where he quipped later: "I shook hands at the rate of 48 a minute, which is 8 percent better than Robb."

Campaigning at the Landmark Shopping Center yesterday morning, Coleman encountered about 200 teen-agers who apparently had skipped school to buy tickets for a concert by the rock group, AC/DC. One youth, apparently aware of controversy over whether Coleman or Robb is tougher on marijuana, called out: "Legalize pot." Others got Coleman to autograph excuses for their absence from school.

Both candidates plan to spend much of the last week of the campaign commuting between vote-heavy Northern Virginia and Tidewater, areas that Coleman advisers call critical.

Coleman will be in the Washington suburbs again Wednesday, Thursday, Saturday and Sunday, and Robb will be here at least today and next Monday.

In the final financial accounting before the election, Robb yesterday reported spending nearly $742,000 during the last three weeks, bringing his total spending to $1.76 million through Oct. 23. Robb's spending, which has already more than doubled the $778,000 spent by Henry E. Howell, the 1977 Democratic gubernatorial candidate, reflects his continued success in wooing the state's conservative business community, which in recent years has supported Republicans.

The bulk of Robb's new spending, nearly $471,000, went to media consultant Robert Squier's Washington firm for producing and broadcasting the television and radio ads, many of them harshly critical of Coleman. Robb has now spent nearly $948,000 for the ads.

Robb also reported spending $103,067 for telephone banks designed to get out Democratic voters on election day and $32,000 for polling, which both campaigns are now doing daily.

The Democrat reported raising $450,431 during the three-week period ending last Friday, with his largest contributions coming from builders and real estate interests. Robb reported receiving nearly $86,000 from the two groups.

Robb's biggest individual contributions included $25,000 from the Democratic National Committee, $10,000 from a Chesapeake real estate firm, $5,010 from mother-in-law Lady Bird Johnson (bringing her total donation to $25,410) and $7,000 from a department store chain that four years ago gave more than $15,000 to GOP candidate John N. Dalton.

Coleman's new report had not been filed as of late last night, but campaign officials said the latest figures show he has raised $2.2 million.

Democrat Richard J. Davis reported spending a total of $288,471 in his race for lieutenant governor against Republican Nathan H. Miller, who reported spending $291,398. Miller, a Harrisonburg attorney, has lent his campaign $100,000 while Davis, a Portsmouth mortgage banker, has lent $50,000 to his.

Republican Wyatt B. Durrette Jr. has spent $406,597, against $317,848 spent by Democrat Gerald L. Baliles, in their race for state attorney general.