The Tory MP, 36, who is campaigning for reelection to his constituency seat in Wells, asked the children for their views as they discussed the topic of Scottish independence.

When one girl said she would vote to leave the UK, Heappey replied: “Why don’t you f*** off back to Scotland?”

The teenager left the meeting and complained to her father, who supports the Scottish National Party (SNP).

Heappey says his comment was intended to be light-hearted. The former soldier, who worked as a researcher for International Trade Secretary Liam Fox, said in a statement: “I made a comment - intended only as a joke – but it was inappropriate and I am deeply sorry for any offence caused.

“I wrote to [the pupil] soon after the school brought her concerns to my attention and apologized unreservedly.”

Tessa Munt, the Liberal Democrat standing against Heappey, said she was shocked by the Tory’s remarks, which were made in March before the election was called.

“School is meant to be a safe place. We send our children to school in the expectation that they will be treated fairly and with respect by people in positions of power.

“I am utterly shocked that the then MP has used bullying, racist and abusive language to dismiss a teenage schoolgirl engaging in political debate.”

Heappey defeated Munt at the 2015 election. Munt’s campaign has been boosted by a win in the local elections this month, when she took the Wells seat from the county council leader, John Osman.

Heappey recently declared himself “pleased” after being cleared of any wrongdoing in a Crown Prosecution Service (CPS) investigation into a breach of expenses rules by a number of Tory MPs.