Go step by step and test.
1. System Preference > Sound > Output > Internal Speakers
Highlight Internal Speakers.
Make sure that Mute is not enabled.
2. Plug in and remove the headphone.
If you see red light in the headphone port, plug the headphone
in and out of the port 5 or 6 times to flip the microswitch inside.
Sound output may be stuck in digital mode.
3. Reset PRAM. http://support.apple.com/kb/PH18761
4. Reset SMC. Choose the method for “If the battery is non-removable”.
5. Try starting up in Safe Mode. https://support.apple.com/en-us/HT201262
Once in Safe Mode, click the “Restart” button at the bottom.
6. Applications > Utilities > Audio MIDI Setup
Audio Devices window
Click the Built-in Output.
Make sure that box is not checked under “Mute”.
Make sure that Format is set at 44100.0 Hz.
Make sure that CH1 and CH2 volume sliders are at the middle and matched.
Right click on the Built-in Output for available options.
6. System Preferences > Sound> Sound Effects
Play sound effects through:
Select "Internal speakers" and then back to "Selected sound output device".
7.Launch iTunes and play a song through headphone and adjust the volume
in mini player.
8. System Preferences > Sound > Sound Effects
Click inside the popup box next o “Play sound effects through” and select “Internal Speakers”.
Toggle it back to “Selected sound output device”
Uncheck the boxes beside “Play user interface sound effects” and “Play feedback when volume is changed”.
Recheck those boxes back.
9. Reset Permissions. https://support.apple.com/en-us/HT203538
10. Contact Apple. https://support.apple.com/en-us/HT203186