What is the best lens to take pictures of cakes? My camera is a Nikon D300s.
Cakes aren't particularly difficult subjects to shoot, so you don't have to be very picky about getting a particular lens.
Having a clear, sharp lens is a good thing, to resolve detail. When I was shooting my wife's cakes, I used my Nikon 50mm f/1.8D for full-cake shots. It's very sharp; it's also nice because it's very cheap.
The only downside is that it might be a bit narrow on your 1.5x crop-factor D300s for the amount of space you have to shoot; you might need more distance than you physically have. But 50mm isn't too tight for many situations.
I also used Tamron 90mm f/2.8 Macro lens. Having a macro lens is wonderful for taking close-ups of fine detail on decorations (in my case, the sugar flowers that my wife made for her cakes). You can use this lens for full-cake shots too, assuming you have space to back up enough.
Macro Lens You may want to consider a macro lens if you're interested in displaying important close-up details. Anything between a 50mm-70mm range would be ideal if your camera has a crop factor.
Tilt Shift Lens Some interesting or other lenses with more creative freedom could be a tilt shift lens. A tilt shift lens will give you more granularity in focus.
To shoot cakes you probably want (at least most times) a shallow depth of field, so a fast lens, medium length. The 50 f1.8 should be ok.
Also, Nikon currently makes two macro ("micro" series) lenses for DX cameras, 60 mm and 105 mm, they both are VR (with optical stabilizer) and AF-S (built in AF motor), both f/2.8. They are a bit more expensive than the 50 mm, about 600 € for the 60 mm and about 800 € for the 105, but they could be useful to catch some small detail. Another reason to get one of these: AFAIK cakes don't move willingly, and to my experience it's easier to get beautiful smooth bokeh with a longer lens than a fast one; this should make up for the slower aperture.
I just realized this last thing I wrote is also a good reason NOT to get these lenses, as you could actually get perfect results and save a lot of money using a Nikon (or other brands, but I won't speak as I don't have much experience there) 18-55 kit lens at its longer end. They're very sharp, give good bokeh (if you get close) in spite of their f/5.6 and focus as close as 30 cm (1 foot).
Of course it's much more pleasant to work with better lenses and you CAN see the difference in overall rendition in some shots, but if you just want some good photos of cakes you don't need to spend that money; it would make more sense to consider one of the lenses I mentioned if you also plan on doing some portraits or macro.
P.S.: If you own an high-end DSLR such as the D300 you probably know the meaning of Nikon's abbreviations (AF-S, VR ans so on), I just try to be clear to everyone.
below: white paper and pizza with eggplants, just resized and white-balanced.
AF-S DX Zoom-Nikkor 18-55mm f/3.5-5.6G ED II, f/5.6, 1/125s, ISO 800. Lighting: indirect sunlight.
I agree with Chris J. Lee above. A short macro lens along the lines of the Sigma 50mm f/2.8 macro would fit the bill very well, it's cheap, sharp and a good focal length for such tasks. I don't think you'd want a macro longer than 100mm with your D300s because the working distance would be too far (for me at least).
A T/S lens would give you better results with regards to maintaining focus planes and getting good DoF. But these tend to be expensive. A Nikon 85mm T/s would be a very good option, if you can afford it!