Sir Peter said the civil service was in "good heart" following a "challenging" time which saw his impartiality questioned by the SNP's opponents.
He will step down as permanent secretary to the Scottish government at the end of June, after five years.
The search for his replacement will begin shortly.
Sir Peter, who hopes to continue in public service, said: "It has been a joy and a privilege to serve these five years.
"However, a person cannot do these jobs forever and I want to enable my successor to come into post in good time for the run-up to the Scottish Parliament elections in May 2016."
'Challenging period'
He added: "I am confident that my successor will find the civil service in Scotland in good heart.
"This has been a vibrant and challenging period. We have come through with our values intact, with strong capability and in a spirit of partnership across Scotland, and with the UK government and its agencies."
Sir Peter was cleared of a breach of the civil service code over an internal briefing advising that the Scottish independence referendum debate had left "the status quo . . . lost in the mists of time".
In 2011, Scotland's opposition parties complained to the head of the UK civil service about Sir Peter, with Liberal Democrat Tavish Scott at the time accusing him of "rapidly becoming the chief cheerleader" for independence.
But the then head of the UK Civil Service, Sir Gus O'Donnell, said it was "right and proper" that civil servants should act to support their elected ministers, in this case the devolved Scottish government.
Constitutional debate
Sir Peter himself has maintained he expressed no view on Scottish independence.
Scottish First Minister Nicola Sturgeon, said: "Sir Peter Housden has been an outstanding permanent secretary, leading the Scottish government's civil service team with distinction over the last five years."
Sir Jeremy Heywood, head of the UK civil service, added: "I would like to thank Peter for his tremendous work as the permanent secretary for the Scottish government, in particular in leading the Scottish civil service through a challenging programme of constitutional debate and change."
Scotland's top civil servant, Sir Peter Housden, is leaving to make way for a successor ahead of the 2016 Scottish Parliament election.