During treatment for a curable STI, having sex can spread the infection to partners or lead to reinfection if your partner is also carrying it. For this reason, clinicians generally advise abstaining from sex - including oral and anal sex - until treatment is complete and, where relevant, a follow-up confirms the infection has cleared.
The exact timing depends on the infection and the treatment used. For some single-dose treatments, you may be advised to wait a set number of days; for longer courses, until the course is finished and symptoms have resolved. Your partner usually needs treatment at the same time even if they have no symptoms.
Follow the specific instructions your clinician gives you, finish any prescribed course completely, and don't restart sex early. A licensed doctor or pharmacist can tell you exactly when it is safe to resume sex and whether a 'test of cure' is needed for your particular infection.