Like an MP, the Prime Minister must swear an Oath of Allegiance. If he or she objected to oath swearing he or she could make a Solemn Affirmation instead.
While holding a copy of the New Testament (or, in the case of a Jew or Muslim, the Old Testament or the Koran) a Member swears: "I�..swear by Almighty God that I will be faithful and bear true allegiance to Her Majesty Queen Elizabeth, her heirs and successors, according to law. So help me God." The text of the affirmation is: - "I �� do solemnly, sincerely and truly declare and affirm that I will be faithful and bear true allegiance to Her Majesty Queen Elizabeth, her heirs and successors according to law".
(
http://www.parliament.uk/about/images/work/oat h.cfm)
The parliamentary oath has a long history. Members were, at one stage, required to take three separate oaths: the oaths of supremacy, of allegiance and of abjuration. Religious restrictions enshrined in the oath effectively barred individuals of certain faiths (e.g. Roman Catholics, Jews and Quakers) from entering Parliament for many years. The option of making a solemn affirmation in place of the oath emerged over time, different categories of people gaining the right at different times. The general right to affirm was established in 1888 following the case of Charles Bradlaugh, who was first elected to Parliament in 1880, but, as a professed atheist, was not allowed to take the oath or to affirm.
(http://www.parliament.uk/commons/lib/research/rp2000/rp00-017.pdf)