Maryland Democratic Rep. Michael D. Barnes opened a Senate campaign headquarters here today as part of an effort to be more widely recognized outside his Montgomery County district.

"This location is extremely important, because Mike Barnes will be in the heart of Baltimore," said his campaign manager, Michael Cryor.

Barnes cut a ribbon in the B&O Building at 2 N. Charles St. in downtown, and he spoke to about 400 supporters about Maryland's needs compared with foreign policy.

As chairman of the House Latin American affairs subcommittee, he has been a leading opponent of President Reagan's proposal to send $100 million in aid to the contras in Nicaragua. That money, he suggested today, could be put to better use on domestic programs.

"Come to Maryland and see what we could do . . . with that money" if it were directed to jobs and housing programs for Hagerstown and the Eastern Shore, he said. "Come with me to Prince George's County and let me show you what we could do with $100 million for education," he said.

But Barnes' chief pitch here today was to the voters of Baltimore, where he is relatively unknown. In a Washington Post poll taken this month, only 2 percent of the registered Democrats said they would vote for him in the primary.

He fares only slightly better in suburban Baltimore County, where 5 percent of those contacted by the pollsters said they would vote for him. By contrast, Democratic Rep. Barbara A. Mikulski, who represents Baltimore and who was the front-runner in the Post poll, was preferred by 64 percent of city voters surveyed.

Also expected to run in the primary are Maryland Gov. Harry Hughes, who placed second in the poll, and Baltimore County Executive Donald P. Hutchinson, who placed fourth, behind Barnes.

Barnes and his campaign staff concede that he may not be widely known in the city. But he said he faced the same problem when he first ran for Congress in Montgomery County and won.

" . . . At this point in March 1978, an even smaller percentage of people knew who I was in the 8th Congressional District than know me in Baltimore now," Barnes said.

Many of those who came today for the headquarters opening were from out of town. Among them were state Sen. S. Frank Shore (D-Montgomery) and Prince George's County businessman Bennie Thayer, president of the state Rainbow Coalition.

Barnes has already spent a considerable part of his time campaigning around Baltimore.

In January, he appeared with Baltimore Mayor William Donald Schaefer, who is an unannounced candidate for governor, at a hearing on the future of the city's port. Today, Schaefer's campaign manager and another top adviser showed up for the ribbon cutting.