When you have a bacterial infection you're usually no longer contagious 24 hours after you start taking antibiotics.
Once you take antibiotics for the bacterial infection the antibiotics start killing off the bacteria and 24 hours later the bacterial infection should no longer be contagious.
So stay home from work, school etc for 24 hours after taking the antibiotics.
If you don't take antibiotics for your bacterial infection you are usually contagious for 24 to 48 hours after the bacterial infection starts going away.
The bacterial infection could last 1 week to 2 weeks and sometimes a bacterial infection may last as long as a month depending on what type of bacterial infection you have.