Ballack-less Germany impress
Germany's makeshift midfield, with Bayern Munich's Bastian Schweinsteiger being granted a few days of extra rest, looked strong with the 23-year-old Khedira in top form.
Ballack was ruled out of the June 11-July 11 tournament in South Africa last week with an ankle injury.
GEAR: Get your Germany shirt
"Sami played very well in the first half," coach Joachim Low, who had to take Khedira off in the second half with a minor muscle problem, told German ZDF television.
"I liked him. He was also very good in organising the game," Low said.
Khedira, who now looks set to partner Schweinsteiger in central midfield at the World Cup, was lively in his fourth international appearance, repeatedly slicing open the Hungarian defence at will with quick, accurate passing in the first half.
Lukas Podolski fired Germany into an early lead with a powerful penalty and Mario Gomez added another in the 69th minute from close range before substitute Cacau (pictured) netted his third goal in his last two matches with a fine solo effort in the 72nd minute.
"We had many chances and overall the team played really well," Khedira said. "This is my favourite position and when I play there I try to help the team as much as possible."
The margin of victory could have been much higher were it not for journeyman keeper Gabor Kiraly, who repeatedly denied the Germans with superb saves in the first half.
His German counterpart, Manuel Neuer, had little work in his first match after winning the starting spot for the World Cup on Friday.
Low made a string of substitutions in the second half, including bringing on midfielder Marcell Jansen, who has recovered from an ankle injury in record time, as he considers which two players to cut from his preliminary 25-man squad by June 1.
Germany, who have been drawn in Group D alongside Serbia, Australia and Ghana at the World Cup in South Africa, play their last friendly against Bosnia in Frankfurt on June 3.