You can apply for permission after building. The council assesses the work exactly as if it had not been built; having built it gives no advantage and no penalty in the decision itself.
When to apply
As soon as you know permission was needed, and certainly on receiving a letter from planning enforcement.
If it is refused
The council can serve an enforcement notice requiring the work to be altered or removed. You can appeal both the refusal and the notice.
The alternative
Where the work or use has existed long enough to be immune from enforcement, a lawful development certificate is the better route.
What to do next
Use the permission checker for a first answer, or see fixed prices for lawful development certificate.
General guidance only. Planning rules differ between councils and nations and change over time, so confirm the position for your property before relying on it.