I won't speak for other countries, but in Australia you're legally allowed to have sex when you're 10 years old.
It works by a process of a two year difference.
10 year olds can have sex with 10, 11 & 12 year olds. But no older or younger.
12 year olds can have sex with 10, 11, 12, 13, 14 year olds, but no older or younger.
It keeps going like that until you're 18 years old, which you can have sex with anyone over 16 years old provided they aren't teachers or special carers etc.