Maybe he wants to help “restore sanity.”

President Obama will make his first appearance as president on the comedy program “The Daily Show with Jon Stewart” next week, days ahead of the midterm election, a White House spokesman said.

The interview’s timing is also notable because it comes just before Mr. Stewart’s “Rally to Restore Sanity” in Washington, D.C.

(Actually, the rally was renamed the “Rally to Restore Sanity and/or Fear” last week because Mr. Stewart’s satiric colleague Stephen Colbert will also be there.)

Mr. Stewart is bringing “The Daily Show” to D.C. next week, culminating in the rally on Oct. 30. Dan Pfeiffer, the White House communications director, said Mr. Obama’s interview would be taped on Oct. 27.

While other members of the Obama administration have appeared on the Comedy Central program, this will be the president’s first appearance.