"Where had you put it?"
Translation:Dove l'avevi messa?
Use lo,la,li,le and l' for direct objects. lo and la are singular, li and le are plural, and l' is used before vowels.
What is a direct object depends on the verb, some examples are what you give in dare, what you put in mettere and what you say in dire... that's the general idea, but you have to become familiar with each verb to know whether the 'it' is going to be a direct object or not.
Ci is a pronoun for when the thing is not a direct object. I find it more complicated and, rather than learning the rules, just remember individual verbs that it goes with. Such as ci penso, which means i think about it.
Check this out, it really helped me understand ci and ne.