Tutorial for: "CiviCRM Event OG Config (sample)" Module
I think the better solution is via Drupal Rules as per this pretty ancient blog

https://civicrm.org/blog/eileen/foray-rules-module

I know that since then we have rolled up modules for clients that deliver the various integrations along the lines of


if Event has custom field = X then create an OG
if a person with Event participant role Y is added to Event make then the OG Admin
if a person registers for the event then create user (if not already have one) and add them to the OG.