CFStringRef state;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state);
if(CFStringGetLength(state) == 0)
{
}
else
{
}
If the status bar is empty, the phone is disconnected - otherwise the phone has an audio output
EDIT:
Remember to add the AudioToolbox structure and import. - Thomas Clayson
, (http://iphone-dev-tips.alterplay.com/2009/12/iphone-silent-mode-detection.html)