If you’ve lost bowel or bladder control? Yes. Right now.
If you are experiencing pain you cannot get away from AND the cause of the pain can be demonstrated as anatomical on imaging studies? Yes, the sooner the better.
That AND is a pretty big one. One of the reasons back surgery has such a poor reputation [someone you know had four back surgeries and is no better or is worse than when they started] is that it took awhile for researchers to figure out that just seeing a disc problem on imaging studies didn’t mean that the problem was actually causing the pain. More than 50% of people without any back pain at all have an identifiable disc problem.
In the last few years, orthopedic surgeons have gotten very good at predicting if the problem is fixable. And, they generally give pretty good advise. If they say you need surgery, you probably will benefit from it. If they say surgery isn’t the answer at this time, believe them and don’t be disappointed.