"I bought five pieces of fruit cake."
Where should the 了go? Sometimes I've seen it after the verb, sometimes after the object
了 has two correct options, depending on the sentence.
Firstly, the given translation contains 了 placed next to the verb, which identifies the action done past.
Secondly, if you place 了 on the right, this also expresses the same thing. The sentence then becomes 我买五块水果蛋糕了。However, the sentence can emphasize "change of state", which has more general meaning.
Could you understand the place of the 了 as:
我买了五块蛋糕 I bought (action done) 5 pieces of cake. 我买五块蛋糕了 I bought 5 pieces of cake already. (to accentuate that you've bought quite a lot)?