You will need to add an ADC IC, like ADC0804/08, with 8051 to interface LM35 (temperature sensor) with it. LM35 is a sensor which outputs analog voltage corresponding to temperature it measures. For every 1 degree celsius rise or fall in temperature its analog output voltage decreases or increases accordingly.
You can measure this analog voltage using ADCs and then process it using a conversion formula(according to its behaviour as stated above) to get the temperature value. Then use this calculated temperature value to perform other tasks like controlling something, etc.
Here is a link that will help you to begin with, "engineersgarage.com/microcontroller/8051projects/interface-ADC0804-AT89C51-circuit"