The screen on my iPhone 5s no longer turns off automatically while I am talking on a call
The most likely explanation for this behavior is that the Proximity sensor in your iPhone is not working as expected. It is a sensor located near the earpiece of your iPhone.



Proximity sensor is responsible for detecting if your iPhone is placed near your face, and in case it is, turn-off the screen automatically. This helps in preventing unintended taps on the screen as well as preserving battery life while on a call.

To resolve, you can try the following steps one by one:


Make sure nothing is obstructing the proximity sensor. A screen guard, dust accumulation, case etc.
Restart your iPhone. This can sometime help in re-setting any software bug/glitch which may be interfering with the working of Proximity sensor.
Update to the latest version of iOS software available for your iPhone. This can help by doing away with any software bug which may be interfering with the working of Proximity sensor.
If everything above fails, you can try by factory resetting your iPhone and see if that fixes the issue.
Your last resort would be to get your iPhone inspected by an Apple authorized service provider or technician and get the Proximity sensor replaced.




Image source: https://drfone.wondershare.com/iphone-problems/fix-your-iphone-proximity-sensor-by-yourself.html