You can use this open source class to determine if headphones are plugged and handle headphones plug or unplugging and audio route changes.
You cannot get programmatically the type of headphones plugged. iPod app detects if you hear from the speaker or from headphones, not the type of the headphones.