Maryland officials filed suit against Energy Secretary James Schlesinger in Baltimore federal court yesterday, charging that the state was receiving less than its fair share of the gasoline distributed throughout the country under the emergency allocation program.

State Attorney General Stephen Sachs argued in the suit that the federal allocation program - in effect since May 1 when the gasoline crisis began spreading across the United States - actually made it possible for some Sun Belt states to receive as much as 22 percent more than their "equitable share." At the same time, he said, Maryland and other eastern states were getting less than they deserved.

"It's my firm legal judgment that this suit has great merit," Sachs said. "The program is illegal. It falls short of the commands of Congress" that gasoline be distributed equitably to all states.

The suit is the first of its kind against the Department of Energy this year but similar to one Maryland officials filed during the Arab oil embargo of 1973-74. Then, an appeals court rejected the suit, but state officials considered it effective because it prompted the federal administrators to release an extra 8 million barrels of fuel to the state.

Gov. Harry Hughes, who met with Schlesinger in Washington Friday, said he hoped yesterday's suit could produce similar out-of-court results. "I hope this problem can be settled administratively," Hughes said at an Annapolis news conference. "But the path to settling things administratively in Washington is sometimes very slow."

In the suit, which will be heard July 5, Maryland asks the court provide the state with temporary relief by directing the Department of Energy to send into the state the same percentage of the nation's gasoline supplies it received in June of last year.

According to estimates prepared by the state energy office, the gasoline supply in Maryland this month will be down 22 percent from last year.

Out on the gas lines, meanwhile, the odd-even gasoline sales plan imposed in Maryland, the District of Columbia and Northern Virginia last week continued to bring some relief, although many service stations reported longer lines yesterday than on Monday.

Some dealers said they have nearly run out of their June allotment of fuel and may have to close down entirely before their July shipment comes in next week. "It's a little tighter than at the end of May," said one officer of the Greater Washington-Maryland Service Station Association.

James Heizer, executive secretary of the Virginia Gasoline Retailers Association, warned that in addition to running out of fuel, some independent dealers plan to shut down later this week to protest what they say are shrinking profit margins caused by federally imposed profit ceilings for retailers.

Similar shutdown protests were threatened yesterday by independent dealers to the north in Pennsylvania and Delaware. Tom Anderson, an official of the Pennsylvania-Delaware Service Station Dealers Association, said that half of the group's 3,600 member stations plan to close Thursday.

And farther north, in the New York metropolitan area, about half the independent service stations were reported closed yesterday out of necessity, not protest. They had run out of gasoline.

According to Sachs and Hughes, many of these states along the north-eastern corridor are suffering because of two major problems with the Department of Energy's allocation system.

The first major problem, they claimed, is that the federal allocation regulations allowed for additional gasoline allocations to regions of the country that could show more than a 10 percent growtn in gasoline purchases during the months of October 1978 through February 1979.

"This is precisely the period when states in this section of the country were experiencing an extraordinarily severe winter and the use of gasoline was sharply reduced," said Hughes. "The net effect of this 'adjustment' is to benefit the Sun Belt regions at our expense."

The second flaw in the federal allocation program, according to Maryland officials, is that the regulations do not take into account the fact that every state is dependent on different gasoline suppliers, all of whom have established different nationwide allocation plans.

In Maryland, for example, roughly 20 percent of the gasoline is supplied by Exxon, which now has a national policy of providing states with 78 percent of the gasoline they received at the same time last year, a percentage that is lower than that set by several other oil companies.

In a state that is not so dependent on Exxon for gasoline, the impact of the 78 percent quota would not be as great as it is in Maryland. Sachs said he believes the Department of Energy has the authority to direct other oil companies to send more gasoline into the state so that Maryland would approach the national average of approximately 90 percent of last year's supplies. Maryland is now getting about 78 percent of last year's supplies.

"Right now, we're simply dependent on the mix of suppliers that we have," Hughes said. State Comptroller Louis Goldstein, who also attended the Annapolis press conference, said he presented that complaint to an Energy Department official last week and was told: "That's the luck of the draw."