The story
From on + pain (“suffering inflicted as punishment or penalty”) + of; compare French sous peine de.
Etymology from Wiktionary, CC BY-SA 4.0.
Today it means: Used to warn of consequences if a specified act is done or not done: subject to the punishment of (some penalty); or (generally) subject to the circumstance of (some thing). Full definition →
From on + pain (“suffering inflicted as punishment or penalty”) + of; compare French sous peine de.
Etymology from Wiktionary, CC BY-SA 4.0.