They are both correct. they would have slightly different meanings though.
“我吃了饭”:means that you've finished your meal. You're done. it can be also used to emphaise what you have eaten, meal, fruit or something else?
“我吃饭了”:means that you're finished with your meal. It can be also used when you're starting to eat your meal.
For example, If you got a phonecall from your friend when you were going to eat your meal, you would say the following,
我吃饭了,稍后打给你。 I'm going to eat, I'll call you back later.
等我吃了饭再打给你。 I'll call you back later when I'm done with my meal.