Ovulation tests

Can someone explain to me how they work, when I should start using them in my cycle and how do I know when to have sex?