Op-amp unity gain buffer introduces distortion in the LM386 circuit with high gain factor
A 9 V battery has a high internal resistance, as soon as the LM386 starts to drive the speaker, it pulls current from the battery resulting in ripple on the battery voltage.
The DC bias you apply to the input signal is derived directly from that supply including the ripple voltage by R16 and R17. So you have some feedback, this output signal feeds into the input as well, that can create all kinds of strange results.
I would add a 10 uF decoupling cap in parallel with R17, that would attenuate the ripple. Then feed that filtered DC bias to the TL071's input via a 10 k resistor.
And as commented you need a better power source than a 9 V battery, it does not have sufficient power to drive an LM386 + speaker. At least not for a reasonable amount of time.