Virginia Attorney General Gerald L. Baliles formally entered the Democratic race for governor today, questioning the energy, commitment and electability of his opponent, Lt. Gov. Richard J. Davis.

Baliles, who has the support of some of Gov. Charles S. Robb's top political advisers, is the fourth major candidate -- two Republicans and two Democrats -- to enter the campaign for governor. The parties will pick their nominees at conventions this summer.

"I'm looking forward," said Baliles, as he attacked Davis, considered by many to be the Democratic frontrunner. "I'm not certain of the extent of his focus on the future. Mine is very determined and energetic."

Baliles' comments brought a quick retort from Davis' campaign headquarters that Baliles, 44, had insulted older Virginians. Davis is 63.

Baliles "is trying to malign any Virginian who is older than he is" by questioning Davis' energy, said Davis' campaign manager, Robert Watson.

Darryl Martin, Baliles' campaign manager, said the comments were directed at Davis alone. "Some people might call it fire in the belly," Martin said, referring to Robb's well-known criticism of Davis' failure to run a vigorous Senate race against Republican Sen. Paul S. Trible in 1982.

Robb, who under Virginia law cannot succeed himself, has declared himself neutral in the Davis-Baliles battle. The party's convention is June 7 in Richmond, but convention delegates will be selected at mass meetings in late March and early April.

Republicans are expected to choose Wyatt B. Durrette of Richmond, a former Fairfax County leg- islator, or Rep. Stan Parris of Fairfax as their nominee at a convention May 31 and June 1 in Norfolk.

Baliles and Davis, who announced in December, have been running for more than a year and clashed sharply late last year over Davis' endorsement by state AFL-CIO labor leaders. Baliles' campaign officials said Davis got the endorsement by secretly pledging to support repeal of Virginia's Right-to-Work Law, which forbids closed union shops -- a statement Davis called a "damned lie."

Without mentioning Davis by name, Baliles said today the governor's office "does not belong to any interest but the public interest. It doesn't belong to any individual, any race, any local geography or any one party. It belongs to every Virginian."

He also raised questions about whether Davis can win this fall. "I have never lost an election and we do not intend to start now," he said. "We are looking forward to a positive, determined and energetic campaign.

Baliles told reporters he does not believe his campaign would be hurt by the possible presence of a black and a woman on the Democratic ticket. "The only race that matters is the one this party is going to run in 1985," Baliles said.

State Sen. L. Douglas Wilder of Richmond, who is black, is so far the only Democratic candidate for lieutenant governor and conservative state Del. Mary Sue Terry (D-Patrick) is the party's only candidate for attorney general. Some white Democrats have suggested the two might hurt the party in conservative Virginia because of perceptions that blacks and women are liberal.

Baliles, a former legislator from the Richmond suburbs who was elected attorney general in 1981 on a ticket with Robb and Davis, said that he would resign his office if he wins the nomination. In 1981, Robb and Baliles both attacked then Attorney General J. Marshall Coleman, Robb's GOP opponent, for not resigning while running for governor.

In his speech today, Baliles acknowledged that Republicans are likely to criticize Democratic officeholders because of the state's troubled corrections system. He said that many of the state's prison facilities, including Mecklenburg Correctional Center where six death row inmates escaped last year, were built while Republicans held the governor's office.

The attorney general also said he supports a drinking age of 21 for beer and wine, and a change in highway funding to give urban areas more funds; might support a referendum on whether to establish a state lottery, and currently opposes any tax increases.

He said he would make education a centerpiece of his administration, but would not necessarily take his two teen-aged children out of private schools and put them in Richmond's public schools as Robb did. "This is a pluralistic society," Baliles said.

Usually a quiet, reserved man in public, Baliles smiled and grasped hands today with a crowd of 200 supporters jammed into a small room at the Mariott Hotel here as "Fanfare for the Common Man" by Aaron Copland played over a loudspeaker and heralded his entrance.

"I like classical music," Baliles quipped, acknowledging that he selected the music.