In System Preferences under Sound, you don't have the Mute box checked next to Output Volume, do you?
I know it sounds basic, but I always start with the obvious when trying to fix something weird like that.
The thing is that everytime I turn on my computer the mute box is checked by default even when I turn off the computer and make sure the sound is not muted.
I just check and if I plug in my headphones just after I turn on my computer the volume gets back to the one I previously had and if I take them out it goes back to mute.
Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.