An oil pressure sensoris used as a safety device to indicate a loss in oil pressure.
In a car when the ignition is switched on the oil pressure warning light is illuminated because the engine is not running and hence no oil pressure is generated. With the engine running pressure is built up in the engine and the oil pressure warning light goes off.
If the engine did not have enough oil when started or it lost oil when running the oil warning light would come on.
The function of an oil pressure sensor is to give rapid indication of a loss in oil pressure that could lead to damage of the equipment.