You are not required to stop working if you have been diagnosed with cancer. On the contrary, research shows that patients who are in a good enough physical health to continue working benefit from a higher quality of life, as being active in the workforce provides needed social contact. .
If you decide to continue working, speak with your employer about any adjustments that may be needed, such as working remotely and/or part-time or changing your role. The same applies if you are returning to work after taking sick leave.
In cases where your treatment is more intense, be it physically and/or psychologically, it may be best to stop working, at least temporarily. Keep in mind that the decision to stop working is not definitive.