Roscoe L. Egger Jr., one of the longest-tenured commissioners of the Internal Revenue Service, will resign at the end of April, the agency said yesterday.

Egger, 65, will have served more than five years, longer than any IRS chief since Guy Helevering was commissioner from 1934 to 1944. Egger's last year has been his most controversial, as he faced criticism for computer and human failures within the IRS that resulted in long delays in return-processing and tax refunds.

When it became clear last spring that the agency's balky new computer system was losing track of tax returns and creating record backlogs of returns and correspondence, Egger put the nation's 10 IRS service centers into overdrive.

The system began to recover, but the public relations damage with taxpayers and members of Congress was severe.

Under Egger, the IRS audited proportionately fewer returns, concentrating on the worst cases involving the most money. He cracked down on abusive tax shelters and tax cheating, frequently bemoaning the fact that the government loses $100 billion annually in uncollected taxes from the underground economy, illegal activities and tax evasion.

In a telephone interview, Egger said he chose this time to leave because "I wanted to stay on, after the difficulties we ran into last year, long enough to satisfy myself we have addressed and dealt with those kinds of problems, so I could leave here feeling good about the place and my part in it."

Egger said he expects to "wind up back out in the private world for a few years." He is a lawyer and certified public accountant.

Asked how he might have done his job differently, Egger said he probably would have placed more emphasis on staffing and taxpayer service. "But I wouldn't change materially the general thrust of the way I've gone," he said.

No successor has been named. One person frequently cited as a possible candidate is Kenneth W. Gideon, formerly IRS chief counsel and now a Washington tax lawyer with the firm of Fulbright & Jaworski. Gideon could not be reached for comment.

Egger will leave during a difficult period for the IRS. Told by Congress to process returns faster this year, the agency faces deep spending cuts under the Gramm-Rudman-Hollings balanced-budget law.

The IRS has no exemption from the law's across-the-board cuts. Proponents assert that it should, because every dollar the IRS spends brings the government an average return of $8 or $9.

To meet the budget cuts, the IRS may be forced to divert resources from other areas to process returns this year, further decreasing audits and other enforcement, according to congressional and other observers.

The administration has said it plans to ask Congress for a supplemental IRS appropriation of more than $300 million for the current fiscal year. The agency lost $157 million in the first round of automatic budget cuts for fiscal 1986.

Egger, whose interactions with Congress sometimes have been heated, also suffered in credibility last year. On April 15 he described as "sheer, utter nonsense" reports that tax returns had been destroyed, then he commissioned an internal report that documented several instances in recent years of returns being stuffed in washroom ceilings or stacked for disposal on loading docks.