Arduino controlled audio amplifier gain?
Make your life easy.  

Use two amplifiers.  

One provides line level output to the back of the device.  Just leave it running all the time. If it isn't in use, it doesn't cost you anything.

The other amplifier provides the headphone output.  Use a simple switch with three poles.  Use it to switch the negative input of the opamp to ground through various resistors.  Place a single, fixed resistor from the output to the negative terminal. 

Like this:







simulate this circuit &ndash; Schematic created using CircuitLab

That only includes two gain settings because the editor on the site here doesn't have a switch with more poles, but it shows you the idea.

The resistor values shown give a gain of 2 (for R2) and 6 (for R3.)  For a gain of 1, you have a pole of the switch that connects to nothing.  Leaving the switch open is a gain of (very close to) 1.

No where is there an Arduino or other microprocessor.  No relays, no complicated logic.You don't even need the switching headphone jack.

As wired, when switching you will have a short moment when SW1 doesn't connect to anything.  In that moment, the gain will fall to 1.  So, you don't have a wild, jumping gain to worry about.  If the contacts in the switch are poor, you might get some scratching while switching - use a better switch.