The PCM receives signals from various sensors (like the crankshaft position sensor, camshaft position sensor, and others) to determine if the engine is cranking or running. Based on that information, it sends the signal to energize the fuel pump relay, allowing power to flow to the fuel pump.
While the PCM is the main controller, there might be safety interlocks involved, meaning that certain conditions (like a crash or low oil pressure) could prevent the PCM from sending the signal even if the key is turned on. These are usually built-in safety features.