Note: This is a sign of failing hardware, and you will likely need to do this more and more often until it fails completely. You’ll need to have your Mac serviced to get this problem fixed for good. Some users have reported better success by using Apple brand headphones or earbuds for this procedure.
Open Activity Monitor from the Utilities folder. Find the “coreaudiod” process in the list. Click the “Process Name” header to sort the list alphabetically. Click the the “Quit Process” button. After confirming, coreaudiod will be closed and will restart automatically.
If you want to play sound from your Mac’s speakers, select “Internal Speakers” or “Digital Out. " If you’re trying to play sound from your connected TV, select the “HDMI” option.