Its not particularly well known that recent Apples support 5.1 surround sound via optical output. The headphone socket on the side does plain audio out for regular headphones.
But get a TOSlink adapter and you can feed the optical into your receiver. Then you'll need an application that can output source to 5.1 optical, such DVD Player.
To make DVD Player output 5.1 go to Preferences, Disc Setup pane and change Audio Output popup from the default to get the disk's 5.1 sound through the optical.
NB This option will only exist if you have a TOSlink connected.