you will have to take this to apple store or service provider to have the SD card removed from the optical drive slot.
the following site gives options for finding these locations near you:
Sometimes it is possible to get it out by turning the iMac on its side.
Shutdown the system, disconnect everything from the iMac; power and any data cables. Then pick up the system and turn it so that the DVD slot is facing down. Gently shake the system. You may need to shake up and down and frot to back. You should hear the SD card moving around.
The iMac is not heavy but can be awkward to hold and shake. If you feel you are not able to do this safely get help or do as iheartapple wrote, take it in to Apple.