The Senate confirmed Martin S. Feldstein as chairman of the Council of Economic Advisers last night by a vote of 77 to 18 after he agreed to appear before a congressional committee holding hearings on the economy during the lame-duck session.

Feldstein earlier had refused to testify at the Joint Economic Committee, citing pressure of work and his lack of Senate confirmation. He had a recess appointment to the CEA chairmanship that would expire at the end of 1983.

Also winning Senate confirmation yesterday as secretary of energy, by a vote of 86 to 8, was Donald B. Hodel, undersecretary of the interior for the past two years.

Angered by Feldstein's refusal to testify, a few Democratic senators threatened to hold up the vote on his confirmation yesterday. Sen. Paul Sarbanes (D-Md.) said that Feldstein's action was an "insult." Other Democratic members of the Senate Banking Committee also opposed the appointment on the grounds that Feldstein was out of touch with ordinary people and insensitive to the needs of the unemployed and elderly.

In the face of the flap, "the White House decided his Feldstein's testimony would be appropriate," a spokesman for the CEA chairman said yesterday. Feldstein will appear before the JEC this morning.

Senate Banking Committee Chairman Jake Garn (R-Utah) said earlier this week that he thought Feldstein should have agreed to testify before the JEC. It was not entirely clear why Feldstein declined. The initial reason was that he was given insufficient notice of the JEC hearings, a staff member said. Then he decided on the basis of pressure of work, together with his lack of confirmation, not to testify this year, the spokesman said.

Some members of Feldstein's staff appeared to have been irritated by the decision of JEC Chairman Rep. Henry Reuss (D-Wis.) to schedule a hearing on Monday although Feldstein could not attend.

A number of Democratic senators still voted against Feldstein's confirmation yesterday, using the opportunity to register their dissatisfaction with Reagan's economic policy and today's 10.8 percent unemployment rate. There are too many rich people in the administration who do not understand the problems of the poor, Sen. Donald Riegle (D-Mich.) said. Feldstein had attacked the Social Security system before joining the administration, Riegle said.

There was no debate on Hodel's nomination, despite opposition from environmentalists over Hodel's background and his close association with Interior Secretary James G. Watt.

Hodel becomes the nation's fourth secretary of energy, replacing former South Carolina governor James Edwards. Edwards resigned to become president of the Medical University of South Carolina.