Some countries have a social security agreement with the UK. This means you will pay National Insurance in the UK while you work abroad.
You will need to get a certificate to prove that you do not need to pay social security in the country that you’re working in.
Check if a country has a social security agreement with the UK and how to apply for a certificate.