Smartphones are usually using capacitive touchscreens. A capacitive touchscreen reacts to changes in the electric field on its surface. If you touch the surface with a finger or another part of your body, the touchscreen is activated. 

However, this function is undesirable when making a phone call, as uncontrolled contact with the display could unintentionally end the phone call. 

To prevent your phone call from being accidentally ended, the touchscreen and display automatically deactivate when you are on the phone. A sensor registers that you are making a phone call and holding the phone to your ear. If you hold the device away from your body, the display activates again.