"I want to hook up my new iMac to my onkyo system via optical cable, is this the adapter I need since the iMac has no optical in?"
You need to tell us more about what you want to do.
Do you want to get sound OUT of the iMac and INTO the stereo, via optical?
Or...
Do you want to get sound OUT of the stereo and INTO the iMac?
What kind of connections do you have on the Onkyo?
I believe the 2012 iMac has an audio out port that works with both analog and optical cables.
To use it with a standard TOSLINK connecting cable, you would need a "mini adapter", such as this one:
http://www.parts-express.com/pe/showdetl.cfm?Partnumber=180-968
To get digital audio INTO the iMac, I believe you will need some kind of USB-based solution.