Beiersdorf's supervisory board and Heidenreich have amicably agreed that he will leave when his term ends at the end of 2019, or earlier depending on when a successor is appointed, Beiersdorf said in a statement. It declined to comment on whether a successor had yet been identified.
Heidenreich's departure follows that of finance chief Jesper Andersen, who is leaving Beiersdorf at the end of the month after the group decided earlier in the year not to extend his contract. It named Nestle investor relations chief Dessi Temperley to replace him.
"We view the management team as a key part of our culture change thesis and view these two resignations within six months as a negative," Morgan Stanley analysts said.
Shares in Beiersdorf, which also makes skin brands such as Eucerin and La Prairie, turned negative, dropping 4.9 percent to a six-week low at 94.58 euros by 1058 GMT.
Heidenreich took over as CEO in April 2012, at a time when Beiersdorf was losing market share to rivals like L'Oreal and profit margins were falling.
Under his leadership the group introduced a new Nivea logo as part of Heidenreich's Blue Agenda strategy, focused on emerging markets, stripped out underperforming lines and regained market share.
Beiersdorf said on Thursday its board had also discussed the further development of the group's Blue & Beyond strategy, the successor to Blue Agenda, including succession and corporate planning supported by growth investments as from 2019.
It said the discussion was partly in preparation for its annual strategy and planning meetings in September and December, without providing further details.
The CEO's departure raises questions over whether Heidenreich might have seen limited further potential from the Blue Agenda going forward, Baader Helvea analyst Andreas von Arx said, and over whether there had been a disagreement with the company's major shareholder on expansion in premium segments.
Earlier this year, media reports emerged that Heidenreich could leave early because of disagreements with the Herz family that controls Beiersdorf via its Maxingvest holding.
Heidenreich told analysts in March that he would fulfil his contract but that he and Michael Herz, with whom he said he had a good relationship, would discuss the matter during the course of the year.
Herz is co-owner of the coffee chain Tchibo, which owns a 51 percent stake in Beiersdorf.
Beiersdorf on Thursday also named management board member Stefan De Loecker, currently in charge of the Near East/Americas regions, to take on responsibility for planning and strategy as deputy CEO from July 1, it said.
(Reporting by Maria Sheahan; Additional reporting by Jan Schwartz.; Editing by Edward Taylor and Jan Harvey)