1. They go BEFORE the conjugated verb.
2. In the Passé Composé, they go before the helping verb. Remember: the past participle AGREES with a COD, but not with a COI.
3. If there are 2 verbs (one conjugated, one infinitive) the COD/COI goes in front of the INFINITIVE -- and you certainly do not make agreements with an infinitive.
Make sure you know the "candy corn" organizer. It tells you which COD/COI comes before which in the case of doubling up.
Ex: I gave them to her. Je les lui donnés.
les devoirs: Write a 8-line conversation (min) in which you cram in as many COD & COI as you can. Make it interesting/funny, and go out of your way to use COD/COI.