When to take STI test?

When is the right time/situation to get tested to see if you have any STI's? Before your first time having sex, or after? Or just when you suspect you may have an infection? And what age do you have to be before you can get tested?  I've only been with one guy and he's only ever been with me, but I'm curious and just wanna make sure we're both safe