You could say "cooked a cake" and that is grammatically correct, but with breads, cakes, cookies etc. it sounds very strange and stilted to native speakers. You should always use "baked". You also never "roast" cakes, breads or deserts.
With meats and vegetables, to avoid confusion you should use "baked" or "roasted" when referring to cooking them in an oven, unless it is either obvious or very unimportant.
I am cooking potatoes au gratin for dinner.
I am baking potatoes for dinner
I am roasting a few ears of corn for dinner.