I have a lot of scanned text in jpeg format, some of them with a dark gray background(very similar colour of the text). How can I remove that background, without affecting the black text sharpness)
Depending on the JPEG compression level, maintaining sharpness could be tricky. I would try adding a Levels Adjustment layer to re-map the grey pixels to white, while maintaining the black type.
Choose Layer > New Adjustment Layer > Levels
The New Layer dialog box appears. Name the layer and click OK.
The Levels dialog box appears.
Drag the Highlight Input sliders towards the center. You may need to adjust the Shadow and Gamma sliders to achieve the white background and the crisp sharp type you desire.
When you're satisfied, click OK.