Hey @dhruv.vhits,
Have you tried using the AVAudioSession interface?
https://developer.apple.com/documentation/avfaudio/avaudiosession/1616443-overrideoutputaudioport
https://developer.apple.com/documentation/avfaudio/avaudiosession/categoryoptions/1616462-defaulttospeaker
Michael