"Professor Dumbledore always valued your views, and so do I."
-- McGonagall to Hagrid when asking his opinion about closing the school (HBP29)
With Dumbledore’s death, McGonagall, the Deputy Headmistress, takes over as Head. Unlike what happened when Umbridge became Head the previous year, the Head’s office allowed McGonagall to enter. Her first duty was to arrange for Dumbledore’s funeral, for which she solicited advice not only from the Heads of Houses but also from Harry and Hagrid.
Dumbledore died during the Battle of the Tower on June 30 and this event happened subsequent to that battle. McGonagall would have become Head the moment Dumbledore died.