John F. O'Leary resigned yesterday as the Energy Department's second-in-command, effective Sept. 4.

In a one-page letter delivered to the White House, the deputy DOE secretary told President Carter:

"As I discussed with your staff on June 22, 1979, I find it desirable to leave the government the end of the summer. I would appreciate it if you would accept my resignation, effective Sept. 4, 1979, if that date is convenient for you."

The Washington Post obtained a copy of the letter from CBS News.

O'Leary, along with Energy Secretary James R. Schlesinger, has been a frequent target for critics of administration energy policies. That criticism has intensified in recent weeks, with gasoline lines lengthening and often conflicting signals coming from the beleaguered Energy Department.

O'Leary had disclosed his resignation earlier in the day, at the National Governors Association meeting in Louisville. After a session on coal transportation, he reportedly told the governors: "I guess this is the last time I'll be meeting with you. I'm resigning."

O'Leary denied last night that he was being forced out, saying he was "just getting too tired" to coninues, according to Associated Press.

The resignation-confirmed by the Whitr House-had been rumored for several weeks. It was learned that the resignation was not requested by the White House, and was not part of any Cabinet-level shakeup emerging from the Camp David "domestic summit."

The timing of the announcement, however, is bound to fuel such speculation. Several governors who met with Carter at Camp David reportedly suggested that new DOE leadership should be the chief executives's first priority.

O'Leary five-paragraph letter was peppered with prasie for Carter and for the president's energy initiatives, suggesting that the resignation was not prompted by any substantial disagreement over energy policy.

"Since January 1977 under your leadership the Congress has begun to put in place the necessary measures for dealing with the Nation's long-term energy problems," O'Leary wrote.

"The creation of the Department of Energy; the passage of the National Energy Act; and other energy initiatives that you have recommended to the Congress will long stand as milestones in the movement of this nation from energy dependency to greater self-sufficiency," the letter continues.

Also, O'Leary said, "I would be remiss if I did notmention the honor it has been to serve under the leadership of Secretary Schlesinger."

Despite the kind farewell words, the highly self-confident and outspoken O'Leary ruffled feathers at the White House on several occasions, and never had a particularly close working relationship with Schlesinger.

The deputy secretary was quoted last week by Energy Daily, an industry newsletter, as saying that he felt he had accomplished in Washington what he set out to do 2 1/2 years ago and that he was considering resigning Sept. 1.

Last spring in an interview with The Washington Post, O'Leary said that the United States was already well on the way to meeting its pledge to the International Energy Agency to reduct oil demand by five percent by the end of this year, and that no mandatory conservation steps would be needed.

The following day Schlesinger at a congressional hearing pointedly disagreed with his deputy's assessment.

O'Leary was skilled at bureaucratic infighting, sources at DOE said. But he accumulated numerous enemiess along way.

The old Federal Energy Administration, which O'Leary headed in 1977 before DOE was created, was about as unpopular in some congressional circles then as the Energy Department is today. Sen. Henry Jackson (D-Wash.) said in 1977 that the FEA "has a woeful record of inadequate regulatory oversight (of) the oil industry."

Before that, from 1972 to 1974, O'Leary headed the licensing division of the old Atomic Energy Commission, and he drew fire there. He wasaccused by several consumer groups of a three-month AEC cover-up of dangers at the North Anna, Va., nuclear power plant. CAPTION: Picture, John F O'Leary, though skilled at infighting, ruffled some feathers.