Less than a year old, take to Apple for free repairs.
Over a year old - Apple uses a generic laptop style slot loading drive. You can find any generic one online and it will probably work, just install it into Apple's proprietary carrier.
Unfortunately the newer Intel iMacs are a lot harder to work on compared to the G5 iMacs (which are awesome to work on in comparison).