You can become a headteacher after working as a teacher in a school. You'll also need several years' experience as a senior manager or deputy head.
You can take professional development training to help with this. For example, the National Professional Qualification for Senior Leadership and the National Professional Qualification for Headship.