What location/restaurant are you asking about?
I've ordered cakes at 1900 Park Fare and Crystal Palace. If you want something customized, I'd call a week or two in advance. If you want the standard 6" cake most WDW restaurants have, you can call 48 hours in advance or even just ask about a cake when you get there. When we were in WDW last month, we changed dinner plans last minute and my mom was able to call the restaurant that day and get a birthday cake for me for dinner that night. This was Kona Cafe at the Polynesian. The cakes I ordered for my kids at 1900 and CP were customized and I made those arrangements 6 weeks in advance (then called to confirm about a week before).
Hope this helps!