Hi, and thanks for your question
Waiting 7 days after taking the medication for a sexually transmitted infection is necessary to get rid of the infection in your body. During that time, you can still transmit the infection to your partners. If you were to then have sex with the same partner beyond that 7 day period, there is a very good chance that person could give the infection back to you, since many STIs are pretty easily passed.
For this reason it is important that you get any STIs treated appropriately and that any ongoing partners also get tested and take the treatment right away to avoid the infection going back and forth between the two of you.
At this point, the person you had sex with after you took the medication, should get treatment for the STI and you both should wait until seven days after treatment before having sex.
Let us know if this does not answer your question or if you have any more questions or concerns.