Drivers from last season's "Chase for the Sprint Cup" lined up next to the president and Johnson's No.48 Chevrolet parked just outside the South Portico of the White House.
"It is not every day that we have a championship stock car parked out on the South Lawn," Obama said jokingly. "I suggested to Jimmie that, in exchange for free parking, he should let me take the 48 out for a few laps. He said that was fine, but Secret Service didn't think it was fine."
Johnson is the three-time Sprint Cup points champion and Petty won it seven times before retiring.
Wednesday's ceremony also was attended by Oklahoma Gov. Brad Henry and Wounded Warriors from Walter Reed and National Naval Medical Center.
LGBT community has 'bullied the American people': Bachmann
Beautician charged with giving client fatal silicone butt injection