He will be replaced by Kensey Foods managing director Andy Stapley who is joining Macphie as chief executive officer in October.
Underwood, who joined as commercial director in 2011, is to leave the company at the end of the year.
He took over the managing director role in April 2014 and was the first person outside of the Macphie family to hold that position.
Chairman Alastair Macphie said: “I would like to take this opportunity to thank Andy both personally and publicly for his significant and lasting contribution to the business.
“He has helped strengthen our unique culture, driven year-on-year growth of both sales and profits as well as strategically streamlining our processes, culminating in the successful implementation of our enterprise resource planning system in 2017. We wish him every success in the future.”
Macphie, which has been in operation since 1928, employs over 300 workers across three sites in Glenbervie in Aberdeenshire, Tannochside in North Lanarkshire and its Midlands Centre of Excellence outside Coventry.