If you have a screen cover, that is the most likely culprit.
If you don't have anything covering the sensor (and you are sure that's what's going on), you need to take your phone back to Apple to see if they can fix it or get you a new phone. If you can't tell if it's working or not, have someone watch as you're on the phone...the phone display should not be on while it's up to your head.