Actually this is the question that I have been wanting to know for long time as I mentioned before about "decírme" - this kind of words and how to put a verb and "me", "se", etc together. So I think you just gave me the beginning of this questions. Is there any rules that you could tell me? Just want to know more about this.
Ok, let me expand those rules:
Direct object pronouns: me, te, se, lo, la, los, las, nos, os, los, las.
Indirect object pronouns: me, te, se, le, nos, os, les.
You cannot use the direct object pronouns with verbs that are used intransitively, so "gustarlo" would be wrong, but not "gustarme".
The imperative requires that the pronouns are attached to it (e.g. ponlo). A negative imperative is done using the present subjunctive, so the pronoun must be in front of it (e.g. No lo pongas).
The pronouns are also normally attached to the infinitive (e.g. ponerlo) and the present participle (e.g. poniéndolo), but they can be placed sometimes in certain constructions (esp. most periphrases):
1) Certain verbs like "querer": Quiero verlo / Lo quiero ver.
2) The periphrasis "Ir a + infinitive": Voy a verlo / Lo voy a ver.
3) The periphrasis "Estar + past participle": Estoy viéndolo / Lo estoy viendo
4) The periphrasis "Tener que + infinitive": Tengo que verlo / Lo tengo que ver.
5) The periphrasis "Deber + infinitive": Debes verlo / Lo debes ver.
But it is not possible with other constructions:
1) The periphrasis "Hay que + infinitive": Hay que verlo / Lo hay que ver.
The list is not exhaustive, of course.