Castex, 55, hails from the centre-right of French politics and served for two years as the second-highest ranking official in the Élysée Palace during Nicolas Sarkozy's presidency.
An Elysee official described Castex as a senior civil servant whose experience in local politics would help Macron connect with provincial France. Castex was a "social Gaullist", the official said in reference to the more interventionist, socially minded wing of France's centre-right.
The announcement followed the resignation of Edouard Philippe ahead of a widely anticipated overhaul of the government by Macron.
Macron is reshaping his government as France grapples with the deepest economic depression since World War Two, a sharp downturn that will shrink the economy by about 11 per cent in 2020 and reverse hard-fought gains on unemployment.