Giles Mercer, who has been in the teaching profession for almost 40 years, is stepping down from his role at Prior Park College.
Talking at the school's annual end of year speech day he explained that it would be the pupils he would miss the most during his retirement.
Dr Mercer said: "It is the children I am going to miss, that is why I became a teacher all those years ago.
"Today is a kind of climax of the year and the perfect opportunity for me to express my gratitude to my colleagues, to the parents and to celebrate the achievements of all the young people in the school.
"I especially want to extend my good wishes to all the leavers."
The speech day went ahead despite the recent outbreak of swine flu, which saw 17 pupils come down with the illness.
Pupils, both past and present, were joined by staff and parents for a celebratory mass, speeches and annual prize-giving.
Dr Mercer, who studied at both Oxford and Cambridge, arrived at Prior Park in September 1996 and his 24 years as a head make him the longest serving Catholic senior school headmaster in the country.
He paid tribute to his wife Caroline and praised his successor, James Murphy-O'Connor, who is the nephew of the former leader of the Catholic church in England Cardinal Cormac Murphy-O'Connor.
Dr Mercer said: "I owe an immeasurable debt to my wife, Caroline, without her support I doubt I would have lasted 24 hours as a head, let alone 24 years!
"I am delighted that the governors have appointed James Murphy-O'Connor as my successor. I wish him, his family and the college every possible success in the next phase of development.
"Everyone has been so kind and supportive to Caroline and myself, through what has been, for us, a most happy period in this thriving community and beautiful place."
The father-of-one said he was hoping to stay in Bath and was looking for a home in the city.
He said: "Caroline and I, as well as my son Edward, love Bath.
"We love the music, literary, theatre and film festivals and Bath Rugby and we take a close interest in Bath's heritage and various developments."
Six Prior Park pupils who have just finished their GCSEs have given up the start of their summer break to take part in a 500 mile charity bike ride.
James Indoe, Rob Dorey, Ludo McCormick, James Gale, Ben Skedd and Will Sexton, all 16, spent nine days cycling to and from Paris.
They hope to raise £1,000 for The Searight Charity, which collects money to buy medical equipment in Calcutta.