Try booting into Safe Mode to see if you still have the problem.
If Safe Mode doesn't make any difference, then try creating another macOS user account. Log out of your main user, then log into the new user. Is there any difference?
The purpose of these two suggestions is to try to eliminate an issue with third party software and a corrupt preference file with the main account, respectively.
Do you have any headphones or external speakers you can use to plug into the headphone jack? Even just a cable with the proper connector would work. There is a possibility one of the contacts inside the headphone jack is stuck and inserting & removing a headphone/speaker cable may unstick the contact which may resolve the problem. Of course if you have working headphones or external speakers, you would be able to also verify the jack is outputting audio correctly. If one of the contacts inside the headphone jack gets stuck against the grounded casing, the system will think something is plugged into the jack.
As a last resort, you can try performing a clean install of macOS or better yet a firmware "Restore". The "Restore" is the better option as it resets the security chip & firmware as well as pushing a clean copy of macOS onto the internal SSD. Keep in mind both options will destroy all data on the internal SSD so make sure to have a good backup first. Just make sure to test the laptop before installing any third party software and before migrating/restoring from a backup. If the problem occurs with a clean install or especially with a "Restore" under these conditions, then it most likely indicates a hardware issue which will need repaired (or some obscure bug since I have not seen any other reports like this).
If no one else chimes in with any other suggestions, you can also take the laptop to an Apple Store or an Apple Authorized Service Provider to be examined.