For underdog Rep. Michael D. Barnes (D-Md.), the name of the game in the senatorial sweepstakes is publicity.

Barnes, who is largely unknown to Maryland voters outside of his Montgomery County district, could face a tough Democratic primary next year against such better known Marylanders as Gov. Harry Hughes and Rep. Barbara Mikulski of Baltimore.

Realizing that his anonymity outside the Washington suburbs poses a major problem, Barnes has kicked his publicity machine into high gear. And his longtime interest in Central American affairs appears to be taking a back seat to issues more of concern in a statewide campaign.

In recent weeks he has toured shelters for the homeless in Baltimore and Washington, trailed by television cameras, reporters and photographers. He has held press conferences, issued news releases and made appearances to speak about everything from federal workers to the Social Security Administration to the environment.

In most cases, said Barnes press aide Bill Bronrott, the scheduled events have gotten Barnes' face on television, his voice on radio and his views in newspapers throughout Maryland.

"We work hard here. We're all over the place," said Bronrott. Reporters have described Barnes as being far more aggressive in generating news than other Maryland senatorial candidates, Bronrott said.

Baltimore County Executive Donald P. Hutchinson, another relatively unknown Democratic candidate for the Senate, has been grabbing fewer headlines, speaking to school meetings and small civic groups. Mikulski, who Barnes readily acknowledges is better known to Maryland voters than he is, has concentrated more on telephoning and handshaking at festivals and other gatherings throughout the state.

Mikulski got statewide exposure in 1974 when she ran against Sen. Charles McC. Mathias Jr. and has been active in national Democratic politics and in women's issues. A recent Baltimore Sun poll, of 404 registered Democrats from across the state, showed Mikulski as the leading Democratic contender in the race, with 38 percent of the vote. Hughes was next with 18 percent, followed by Barnes with 16 percent.

Hughes, who has not announced for the Senate seat but has formed a committee to explore the possibility of running, has not had trouble getting his name in the papers. But most of the stories have been about the state's savings and loan crisis.

Barnes' initial publicity coup occured Oct. 11, less than a week after his announcement. His staff said that, as chairman of the Federal Government Service Task Force, Barnes had obtained copies of documents from the Defense Department stating the department's intention to ask Congress for sweeping changes in the federal civil service system. The proposal would replace the pay and grade scale with a pay-for-performance approach.

Defense Department officials said that a pilot project testing the system with engineers and scientists has been successful. Barnes blasted the DOD proposal, saying it would "politicize the federal work force. . . . "

The documents and his tough statement got Barnes in newspapers throughout the area, although it also put him at odds with Rep. Patricia Schroeder (D-Colo.), chairwoman of the House subcommittee on civil service. Schroeder issued a press release and wrote the Office of Personnel Management, declaring her support for the pilot project. Schroeder did not mention Barnes by name, nor did she endorse the DOD proposal. But she said the proposal was "worthy of serious consideration. . . . "

Barnes was accused by some of disclosing the documents to get his name in the paper. Bronrott contends that Barnes was sincerely concerned about the DOD plan.

People are always more "skeptical" during a campaign, Bronrott said. "We work hard to get real news stories."

A short time later, Barnes took the two-day tour of shelters in Baltimore and Washington, a tour that got him a fair amount of publicity.

A few days after that, Barnes held a press conference to publicize his concern about proposals to reduce staff at the Social Security Administration, which is based in Baltimore County and has offices throughout the state. Most major papers and radio stations in Maryland carried the Social Security story.

Then, at the height of the recent floods, a Barnes staffer called reporters to announce that President Reagan had signed an appropriations bill that contained $180,000 for the Army Corps of Engineers. Barnes had gotten the money included in the bill for flood control projects on the Potomac River. Reagan had signed the bill the week before, but Barnes' aide said the congressman had just learned that Reagan had signed it.

Next on the agenda is a press conference at the National Aquarium in Baltimore, a city that will be one of Barnes' major battlegrounds. He will present 10,000 copies of "The 1985 Citizen's Guide to the Ocean" to the Maryland State Department of Education. The gift is being made on behalf of the Center for Environmental Education, a conservation group concerned with protecting the ocean and marine life.

Bronrott said that newsmaking activities will be stepped up even more in the coming months.

"We are indeed off and running," he said.