If you're off work but are still being paid (e.g. paid maternity leave or sick leave), you can continue to pay into your pension and you'll still receive tax relief on your payments (on up to 100% of your annual earnings and also subject to an upper annual allowance of £40,000). If your employer is paying into your pension, you'll need to check with them whether they'll continue to contribute while you're off work.
If you have time away from paid work, remember you can stop payments into your personal pension if you need to. You can start saving again whenever you wish. If you do make payments into your pension you'll still receive tax relief on up to £2,880 of payments each tax year, even if you have no earnings for that tax year. You can pay in more than that if you wish but you won't receive tax relief on the extra amount.