Most likely this is what you are looking for:
UInt32 overrideValue = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(overrideValue), &overrideValue);
From the docs: Specifies whether or not to route audio to the speaker (instead of to the receiver) when no other audio route, such as a headset, is connected.