It is most likely your proximity sensor. If you have a screen protector, try remove it. Also clean the earspeaker with a toothbrush with some alcohol on it. If you have broken screen also it might cause the problem. Proximity is the sensor that understands ehen you place your phone close to your ear and the screen is going black to avoid random touches on the screen, so if something is blocking it (dust, broken screen, etc.) then your screen is going black.