Default Nexus 4 Ear Speaker Not Working

I have a nexus 4 16gb running android 4.4.2. Last night I tried to make a call and the ear speaker wasn't working. It worked fine when connecting headphones but not without it. I left the phone off at night. The next morning I turned the phone on and tried making a call and the ear speaker worked fine. However that afternoon the ear speaker stopped working again. What could be the problem??? Could it be a hardware or software issue?