Snape was a headmaster in Harry Potter and the Deathly Hallows .
Harry alerts the teachers that Voldemort is planning an assault on the school , and not realising that Snape ( now headmaster ) is a re-doubled agent acting for the good side and has important information for Harry , they drive him out and summon the Order of the Phoenix to help defend the school to win time for Harry to locate the horcrux .
Harry Potter and the Deathly Hallows