This is a Tasker plugin. BlueTask allows audio routing using BT headset. In addition it can intercept the pressure of headset buttons, about the setup: after the button has been pressed with the screen on of your smartphone, select "BlueTask" when the system shows the popup "Complete action with" and select "Always".