The president has been eager to redirect public anger over gas prices as Democrats try to keep power in Congress in the midterm elections.