I had similar problems with my xperia headphones and speakers , I believe it was caused by one of the windows creator updates, too much of a coincidence.
This is what I did to fix it.
- Go to device manager/ sounds and mic tabs then right click and uninstall drivers even if they dont have a yellow triangle on them. Windows will reinstall them on restart.
- In sounds/playback tab right click and disable the realtek digital output. just above the icon when using SPEAKERS you should see a green tick in the speaker icon , right click if missing. When you plug in your headphones the icon will go out and if you scroll down you will see a new one for headphones . when you swap between speakers and phones it takes a few seconds to find new device.
- check properties tab on both headphones .... green jack highlighted and microphone pink jack. finally at bottom right corner where the speaker icon is change the tab to realtec high def audio , i have my volume at 50%
FOOTNOTE since another windows update my phones/mic wont work on a game unless I plug them in before launching the game.