Obama refused to comment directly on a leaks investigation in which the phone records of Associated Press employees were obtained in a national security investigation.
But speaking in general, Obama said: "Leaks related to national security can put people at risk. They can put men in women in uniform ... they can put some of our intelligence officers ... at risk."
He said it was his job as president to protect those who might be put in harms' way.
Asked whether the administration's request to Congress for a new "media shield law" indicated some kind of White House criticism of the AP investigation, Obama said there needs to be balance.
"The flip side of it is we also live in a democracy, that a free press helps hold me accountable and helps hold the government accountable," and the media should be able to inform the public, Obama said.
Pressed by reporters, Obama said, "I have complete confidence in Eric Holder as [U.S.] attorney general."
Obama appeared at a joint White House news conference with Turkish Prime Minister Recep Tayyip Erdogan.
Holder told a House committee Wednesday he assumed the White House learned of the AP subpoena "in the newspapers."
Holder told Republicans on the committee the Justice Department does not inform the White House of ongoing investigations.
He also said he didn't participate in the decision to subpoena phone records from the AP.
Holder told the House Judiciary Committee: "I was recused in that matter. ... I am not familiar with the reasons why the subpoena was constructed in the way it was. ... [However] I have faith in the people who were responsible in this case."
The subpoena for phone records of about 20 AP employees came in the investigation of media leaks of U.S. Justice Department information.
Holder said he withdrew from the process because "I am a fact witness in that I am a possessor of the information that was leaked." He confirmed that the subpoena process was overseen by Deputy Attorney General James Cole.