Not sure but
Does the speaker ever work ie can you hear the other party in phone calls? Does it make a sound when turned on after being powered off? If no then either blocking mode is enabled, the volume is off or the speaker has become unwired.
If it does sometimes work its very probably a setting. I imagine you have already looked but check
sound - volume - all are turned up
device ringtone & default notfication are not set to silent