Several options. The most common for battery/DC jack powered devices is to use the DC socket's normally closed switch to route the ground of the battery to the ground of the circuit. When a plug is plugged in, this is disconnected and the outer connection of the DC plug is connected to circuits ground - disconnecting the battery.
Other options are, use a diode on each power input with their cathodes connected - the higher voltage supply with be the one that powers the circuit. The downside with that is, you'll lose ~0.6V (~0.2-0.4V for schottky diodes) of the battery voltage, which for portable applications just reduces battery life/efficiency.
https://tangentsoft.net/audio/cmoy/bitmaps/diode-or-bridge.pngMore complicated (but still straightforward) options are to use a P-channel MOSFET on the battery input, with its gate pulled down to ground with a resistor. The gate can be pulled 'high' (so the FET is off) when power is applied to the DC jack, using transistors to invert the signal.
Like i said, many ways to do this, its a question of efficiency, cost, but by far the most common is using a DC socket with switch: