@milaidin :
Poking around in the schematic shows that the Audio jack has a switch pin connected to a line labelled HP_DET on the board. As far as I can tell this line is pulled low via R47&R48 unless there is a plug inserted. when it is pulled high via R49 instead.
This HP_DET line does not go directly to the P4 chip, instead it goes to U6, which is a I2C I/O expander chip on the system I2C bus.
If the source for the demo is available look for how this line is read, then turn the amplifier on/off as needed. The code for that should also be in the demo.