As
@aditya.a.s.singh.18 mentioned, this sounds like a Smart Lock issue.
In Settings>Security and lock screen>Smart Lock>Trusted devices, ensure that your headset is not a trusted device if you do not want this behavior to happen.
If that doesn't resolve the automatic unlocking issue, please update this thread.