Note: these notice periods apply to employees resigning or retiring – different rules apply to notice periods for dismissal (you can find these in the Burgundy Book).
Statutory and contractual notice periods
Check your headteacher's contract first, as it should include their notice period.
Statutory notice periods for headteachers in maintained schools are set out in the Burgundy Book (the Conditions of Service for School Teachers in England and Wales, hosted on the National Education Union's website). Academies, foundation and voluntary-aided schools don't have to follow this, but most do.
Headteachers are required to give 3 months' notice in the autumn and spring terms and 4 months in the summer term. See pages 4 and 5 of the Burgundy Book, linked above.
However, most headteachers' contractual notice periods are longer than the statutory ones, and longer than for other teachers.
Term when notice is given Minimum notice period Notice