The new deal to sponsor the current world champions comes as VW struggles with the fallout of its "dieselgate" emissions cheating scandal and Mercedes-maker Daimler also faces accusations it rigged air pollution tests.
The advertising marriage of VW and "Die Mannschaft", as Germans call their team, starts on January 1, 2019 and runs until July 31, 2024.
No financial details were released, but German media said Wolfsburg-based VW would pay the German Football Association DFB €25-30 million ($28-34 million) a year, far more than Daimler has paid.
"Volkswagen and the number one national sport -- that's a great partnership," said Herbert Diess, CEO of the Volkswagen brand, pledging that it was committed to "all German football, with its 25,000 clubs and seven million members (of the federation)".
DFB president Reinhard Grindel said: "Volkswagen, as a globally operating company, is a strong partner to further advance our internationalisation, especially in China."
He hinted at the emissions cheating scandal, saying that "the DFB and VW are united on the need to learn from past mistakes and take the right measures in the future".
Volkswagen Group, which also owns Audi, Porsche, Seat and other brands, in 2015 admitted that it had manipulated emissions readings on some 11 million diesel vehicles worldwide.
Investigators found that VW used so-called defeat devices, making vehicles appear to comply with environmental standards when actual emissions were much higher.
The carmaker has so far set aside more than 22 billion euros to cover fines and compensation related to the scandal, but experts estimate the final bill could be much higher.
VW has since pledged to become the world leader in clean, electric vehicles, and Diess said that "for the next few years, we have set ourselves a lot of goals as a company".
"Volkswagen is changing. We face great challenges. This includes helping the breakthrough of electro-mobility," he said, adding that "the partnership with the DFB will help us to reach the people" with these ideas.
Meanwhile, Stuttgart-based Daimler has also been accused of having manipulated the engines of around one million diesel vehicles.
German daily Sueddeutsche Zeitung and two broadcasters, citing a search warrant, said the company "sold vehicles with higher levels of damaging emissions than allowed for almost a whole decade between 2008 and 2016, in Europe and the United States".
A Daimler spokeswoman contacted by AFP declined to comment on an ongoing investigation, but said the carmaker was cooperating with the authorities.