Both of your Italian sentences are correct: the first one makes use of a so-called “intensive” use of the verb.
First of all, assume the sentences are in the present tense. In this case we would have, for the two Italian sentences, Se lo mangia il cane and Lo mangia il cane. Here the only difference is that we have in the first case an additional personal pronoun to give some emphasis and to convey a sense of involvement in the action. It is a common construction, especially in the spoken language: Mi bevo una birra and Bevo una birra (“I drink a beer”), Ci vediamo un bel film and Vediamo un bel film (“We watch a great movie”). In these utterances, the first construction conveys a sense that we really enjoy the experience, so to say.
Beware, this are not reflexive verbs: mi vedo allo specchio (“I see myself in a mirror”) is a reflexive construction; mi vedo “Guerre stellari” (“I watch Star Wars”) isn't.
And, apart for the pronoun, there is another grammatical difference. All these examples involve transitive verbs which, usually, use the verb avere as their auxiliary:
- Bevo una birra -> Ho bevuto una birra
- Vediamo un film -> Abbiamo visto un film
The “intensive” construction, on the contrary, requires essere as its auxiliary:
- Mi bevo una birra -> Mi sono bevuto una birra
- Ci vediamo un film -> Ci siamo visti un film
(Notice visti rather than visto, agreeing with the subject, as is usual when the auxiliary verb is essere).
So we have arrived to your example. The pronoun l[o] is just a normal object (referring to il compito, the homework, in this case). So we may have either L'ha mangiato il cane (corresponding to Vediamo un film) or Se l'è mangiato il cane (corresponding to Ci siamo visti un film).
Some further fine points:
- The subject (il cane) is at the end for emphasis; Il cane se l'è mangiato would emphasise mangiato, as in, he didn't rip it or hide it, but actually eat it;
- Here mangiato doesn't agree with il cane (or it does, but by chance) but with the implicit il compito. This is normal when the participle follows an object expressed by a pronoun and isn't a consequence of the intensive verb: ho mangiato la bistecca but l'ho mangiata.
You can find some more information (in Italian) about this kind of construction here and here.