When is surgery needed to treat sinusitis?

Depends. Surgery is a treatment and not a cure for sinusitis. So if you have been on previous maximal medical therapy and not responded then surgery may be an option: indicated for 4 or more sinus infections per year or evidence of chronic sinusitis affecting life-style. The indications can vary so it is important to talk with your ENT surgeon. If you feel uncomfortable - get a second opinion.
Failed medication. In general, when a sinusitis patient has been tried on maximal medical therapy, then surgery would be needed. That said, there is some disagreement among various doctors as to what constitutes "maximal" medical therapy. In the end, treatment should be customized to the particular patient.

Related Questions

Is fungal sinusitis treatable without surgery??

Depends. On the extent of sinusitis and whether there are other issues, like bone erosion or other structures affected in the same area. Your ENT would decide based on history, physical exam, lab results and imaging studies. Better to get the input of an allergist/immunologist as well, if feasible, best wishes.