Germany, Spain and Argentina are the only sides from the four-nation group that remain unbeaten in the tournament.
The hosts beat Italy 3-0 in their opening game, but it was the defending champions that came closest to a breakthrough when they were denied a penalty by Italy keeper Antonio Pizzurri in the closing seconds.
The result is the first of five straight victories for Germany in the knockout stages and the first since 2008.
Spain had lost the previous two matches and had failed to qualify for the tournament for two successive years.
“This game will give us a great opportunity to take advantage of this incredible stage,” said Germany manager Joachim Loew, who was appointed by Germany in August.
“We had some big chances in the first half and unfortunately we didn’t manage to capitalise on them.
But the way we defended, the way the team defended and the way they defended in the second half is a very good indication of how well we are playing.”
Spain have won the last two matches of the group stages, beating England 3-1 in a last-16 tie in September.
They were eliminated in the quarter-finals of the 2010 World Cup.
Spain have also reached the knockout stage in three of the four previous seasons.
They beat England 3 to 0 in the last 16 of the 2008 edition.
The draw was held on Friday night in the city of Hamburg, Germany.
The Spanish draw was announced by FIFA, which is responsible for organising the tournament and who have not commented on the result.
Argentina have already qualified for the knockout rounds, losing 1-0 to England on Thursday.
The Argentinians are hoping to add to their three-game winless streak by taking on France in the group stage next Saturday.
The French side lost 2-1 to Belgium in the previous round, while the hosts beat Bosnia-Herzegovina 2-0 on Friday.