Two new Virginia polls suggest that President Carter, although still trailing, is showing surprising strength in a state that Ronald Reagan had been expected to carry easily.

In a telephone poll released today by Media General Inc., Carter trails Reagan by a 40-to-34 margin, with 8 percent favoring independent candidate John B. Anderson and 18 percent undecided or not responding.

Another poll, conducted for the Republican Party of Virginia by North American Marketing Corp. here, is said to show a slightly wider margin for Reagan but with still enough undecided voters to swing the election to Carter.

Commissioned by the Richmond Times-Dispatch, the Media General poll of 519 registered voters has margin of error of about four points. That means Reagan could conceivably be ahead by as much as 14 points or behind by as much as two points to Carter.

Nonetheless, the poll suggests that with more than a month remaining until Election Day, Carter has at least a respectable chance of victory in the only southern state he lost to Gerald Ford in 1976. Accordingly, many in the state Carter organization are upbeat.

"Reagan's ahead but we've been gaining on him since midsummer," said William Romjue, state director of the Carter-Mondale campaign. "I think we can win it."

The Reagan-Bush state campaign's executive director, Robert Hausenfluck, conceded the six-point difference between Reagan and Carter indicated the race has tightened up considerably.

"If we're just six points ahead then we need to do a little more work than we've been doing at the grass-roots level," said Hausenfluck, adding, "We have plans to do just that."

Neither Republican Party officials nor North American Marketing president William A. Royall Jr., would release data from Royall's new poll, although Royall said, "I can't quarrel with the numbers [from the Media General survey]. . . . They indicate it's going to be a tough race for Reagan although I think he can carry Virginia if everyone gets their act together."

Reagan officials had predicted a major victory in Virginia and just last week, Reagan state chairman John Anderson cited an August GOP poll that he said gave the former California governor a 12-point lead here. Reagan national campaign officials were so confident of winning Virginia that they designated only about $25,000 for the state committee's budget, leaving the state GOP to provide most of the money and manpower for the campaign.

The Carter campaign has budgeted a similar amount for Virginia, although for a much different reason: Carter operatives were convinced they could not hope to carry what is considered one of the nation's most conservative states. A Virginia Democrat with close White House ties said just last week that the Carter campaign had "written off" the state.

Even so, both Rosalynn and Chip Carter have made tours of Virginia in recent days with Chip Carter claiming publicly that the campaign had "targeted" Virginia for victory.

The Media General poll, taken the week of Sept. 17-23, suggests that uncertainty over Reagan, rather than high regard for Carter, motivates many of the state's voters. Other polls have indicated a similar trend nationally. o

While Reagan is chosen by 41 to 30 over Carter as the man who could best handle the national economic situation, the margin slips to 35 to 33 on the question of international affairs. Anderson gets between five and six points on both questions, with the rest undecided.

As expected, Carter decisively captures black votes in the poll, winning 75 percent to only 9 percent for Reagan ad 3 percent for Anderson. Reagan wins white voters by 45 to 29 percent. Blacks make up nearly 19 percent of Virgina's population but usually come out in considerably less numbers than whites on election day.

The most recently published Washington Post poll, conducted Sept. 3-7, showed Carter and Reagan at a dead heat nationally with 37 percent each and 13 percent for Anderson.

Anderson's lower standing in Virginia reflects his generally lower rating in the South. All but 25 of the voters polled by Media General were contacted before last Sunday night's Reagan-Anderson debate.