WASHINGTON — President Obama has submitted himself for a grilling on the set of “The Daily Show” with Jon Stewart three times. But on at least two occasions, Mr. Obama also secretly met with the comedian on his own imposing turf.

In 2011 and again in 2014, Mr. Stewart came to Washington for coffee with the president, entering the White House grounds at the entrance where the public tours begin. He shook hands with several tourists and was escorted to the Oval Office for his one-on-one sit down with the commander in chief.

He joked in 2011 to his escort that he felt like he was being called to the principal’s office.

The two meetings — recorded in the official White House visitor log — were first noted this week by Politico. Current and former White House officials confirmed the visits, describing them as efforts by the president and his communications team to tap into Mr. Stewart’s influence with younger voters.

“Jon Stewart was a key influencer for millennials,” said Dag Vega, who worked for several years at the White House developing relationships with media figures. “They relied on him for an honest take on the news, and the president and senior staff know that.”