you should know two things:
1) verb + 了 = past tense
so, he bought this sweater for me = 他给我买了这件毛衣。
2) if we put a "了" at the end of a phrase, it means that something new happened or something new will happen.
for example, 下雨了 (happened) 就要下雨了 (will happen)
anyway, in this case, 了 emphasizes some change, it expresses some emotion of speaker.
so for your example: 他给我买了这件毛衣了, the second 了 tells us that you are trying to express some emotion. maybe someone is asking you like this: didn't he buy this sweater for you? or maybe “他” bought you this sweater to surprise you and now you are telling us about that. Anyway, the second 了 tells us that you are trying to emphasize the change: from "you have no sweater" to "you have it".