This question comes up all the time!
I’m sorry but I don’t have the magic answer – it truly depends on each individual circumstance.
However, I’ll try to be general and say that in most cases work is fine, its unlikely to make you worse. Some jobs may aggravate your pain but this is a normal function of your nervous system trying to protect you while you heal. It’s very important to listen to your body and don’t dose yourself up with a cocktail of drugs in order to get through the day (this will mask the problem and make it very difficult for your nervous system to protect you).
If your work/employer will allow you to take regular breaks, to not stay in one position for a long time and to make reasonable work place adjustments, then go for it. Remember that you are likely to feel worse when you are tired, this is normal. If there is significant risk of further injury at work e.g. you injured yourself laying bricks and bricklaying is your job, there is no other work on site that you can do while you recover, then it’s probably not a great idea to go back until you are able to lay bricks all day again.
Good communication with your employer (or HR department) and with your fellow employees is important.