Republican Lawrence J. Hogan, in a last-minute effort to sell himself as an alternative to Democratic Sen. Paul S. Sarbanes in Maryland's Senate race, stepped up his attack on the incumbent yesterday, charging him with accepting illegal campaign contributions.

In a live debate on Baltimore's WMAR-TV, Hogan accused Sarbanes of holding an illegal fund-raiser outside the country and of accepting more than the maximum allowable contribution from a single group. Hogan, the Prince George's County executive, asserted that Sarbanes had received $23,000 from the Council for a Livable World, a contribution $18,000 in excess of the maximum allowed by law.

Sarbanes, who holds a strong lead over Hogan in recent polls and has raised $1.3 million in contributions -- more than three times the amount raised by Hogan -- denied both allegations.

The fund-raiser outside the country, Sarbanes said, was held by Americans meeting in Toronto for a Greek-American fraternal organization's yearly conference. Sarbanes, who is of Greek ancestry, said he attends the function every year.

After the debate, a Sarbanes aide said that the $23,000 Hogan referred to had been raised through individual contributions from people who had been solicited by the Council for a Livable World. The council has solicited money for as many as 20 candidates, the aide said.

Hogan's attack appeared to be an attempt to blunt what has become a major issue in the race: the $625,000 anti-Sarbanes media campaign mounted by the National Conservative Political Action Committee (NCPAC). In earlier debates and again last night, Sarbanes said that the NCPAC, which also has paid for television commercials favorable to Hogan, is involved in "a vicious campaign . . . of political deceit and deception."

Sarbanes urged voters to "send them a message on Nov. 2" that such tactics will not work in Maryland.

Hogan replied that Sarbanes "has whined about little else in the campaign," and accused Sarbanes of using the NCPAC issue to distract voters from his "do-nothing record."

The two candidates squared off on other familiar territory. Sarbanes attacked Reagan's economic program as a course "heading the country downward."

Hogan retorted that the country's economic problems "didn't all start the day Ronald Reagan took office" and said the economy is showing "hopeful signs."