Is it safe to have back surgery when sick?

Depends. When spine surgery is elective (not an emergency, such as for paralysis), it is best for a person to be well. If you have a serious infection or medical problem (like angina (chest pain), uncontrolled sugar (diabetes), uncontrolled high blood pressure, recent heart attack, recent heart stent required blood thinners) surgery should wait until those problems are addressed.
No ideally you . Want to be in optimal condition to minimize any risks or complications unless the surgery is an emergency issue.