**UPDATE**

The original question did not make it clear that it was asking about mideoraiisah or miderabbanan. I asked my rav and he said it was miderabbanan

----

**ORIGINAL**

While one is forbidden to eat before havdallah (but after tzeis) one is allowed to drive after having davened maariv. In the shmone esrai we say ata chonantanu (which is the baruch hamavdil beain kodesh lchol) in order to allow driving home from shul before making havdallah at home. Thus, if a person (say at home) has not davened maariv yet, then he must say baruch hamavdil before performing a melacha. If he has realized that he has done a melacha, then he should immediately say baruch hamavdil and the error would be a shogeg.

As an example:
[Chanukah 5780 – Halachot and Frequently Asked Questions](https://judaism.stackexchange.com/questions/118675/does-a-melocho-done-after-tzeis-hakochavim-but-before-havdoloh-count-as-a-meloch)

> Motzei Shabbat: When Shabbat ends (after 5:14 PM) (Please Note: There
> are different customs with regards to the order of the Chanukah
> candles and Havdalah. If your family custom is to light Chanukah
> candles first, you must say “Ata chonatanu” or “Baruch hamavdil bein
> kodesh lechol” before striking the match.)