Lawrence J. Hogan, the Republican candidate for U.S. Senate in Maryland who is trailing badly in recent polls, sought desperately today to shift attention away from controversial television advertisements against his opponent which have become an albatross to his campaign.

In a television debate, Hogan charged that Democratic Sen. Paul S. Sarbanes, who has repeatedly criticized the ads, was using "an extraneous diversionary tactic" to "cloud and distort" the issues.

Sarbanes has stressed in speeches and in last week's initial debate with Hogan that Hogan had welcomed the ads by the National Conservative Political Action Committee instead of working to keep the election free from "outside manipulation." Today he justified his attacks on NCPAC by saying that any group "that has spent nearly $700,000 to manipulate this election is not irrelevant."

Exasperated at the end of today's debate by Sarbanes' persistent efforts to focus media and voter attention on NCPAC, Hogan threw up his arms and declared: "I hereby denounce NCPAC. If you are out there listening, NCPAC, I denounce you for the 50th time in this campaign. Now let's talk about something else."

Hogan and other Republicans have been worried that NCPAC's portrayal of Sarbanes as "too liberal for Maryland" is backfiring in this predominantly Democratic, heavily blue-collar state.

Hogan, frustrated because a lack of finances have prevented him from waging an all-out television advertisement campaign, must rely increasingly for exposure on a series of television debates scheduled before the Nov. 2 election.

As evidenced by today's debate, which was sponsored by the Maryland Center for Public Broadcasting and will be aired Saturday night, Hogan will try to seize the role of aggressor and emphasize his belief that Sarbanes "is a do-nothing senator." (Last week Hogan labeled Sarbanes "an inept wimp.")

At one point, as Sarbanes recounted that his father was a working-class immigrant who treasured the privilege to vote, Hogan pantomimed a violinist, chiming in a moment later, "I come from the same background as my opponent."

The 30-minute exchange between the two candidates revealed predictable conservative-liberal differences on issues such as the economy and the Middle East.

Sarbanes emphasized his opposition to President Reagan's economic policies as he has throughout the campaign.

"The president says we must stay the course," Sarbanes said. "Many people can't stay the course. They're falling off the course." He blamed Reagan for the nation's 10.1 percent unemployment rate, for farm failures, bankruptcies, disastrous environmental policies, and for what he termed "an assault" on the nation's retirement and Social Security programs.

Hogan, who has stated frequently that the election is not "a referendum on Ronald Reagan," blamed the nation's economic woes on competitive foreign markets and on the policies of former Democratic president Jimmy Carter.

In their discussion of the Middle East, the candidates, both of whom will address Jewish groups over the weekend, voiced similar commitments to Israel and to the restoration of Lebanon. Hogan, however, said he opposed negotiating with the Palestinian Liberation Organization, which he called "a direct Soviet agent."