When I insert headphones I see it in Settings->Sound->Output instead of speakers but sound plays through internal speakers anyway.
The only way is to execute
amixer -c 0 sset "HP/Speaker" on
to switch headphones on and
amixer -c 0 sset "HP/Speaker" off
to switch it off back to speakers