How to create new entity within a hook?
That code needs to be changed for the following reasons.
In PHP, $entity-&gt;getEntityType() == ('Deadline' || 'Message') doesn't check that $entity-&gt;getEntityType() returns either 'Deadline' or 'Message'. Actually, the code you wrote is equivalent to the following one.
if ($entity-&gt;getEntityType() == TRUE) {
  createNotification($entity);
}

getEntityType() doesn't return the ID of the type of the entity, but its definition. The method that returns the ID of the type of the entity is getEntityTypeId().
It doesn't make sense to check the value returned from $entity-&gt;getEntityTypeId() in hook_ENTITY_TYPE_create() because hook_ENTITY_TYPE_create() is invoked only for the ENTITY_TYPE entities. (You are also supposed to implement hook_ENTITY_TYPE_create() by replacing ENTITY_TYPE with the entity type, for example node for the Node entity, or user for the User entity.)
EntityInterface is an interface, not a class; as such, it's never used to call a method, even if it's statically called as in the code you are using.
The correct code is similar to the following one. I assume that ost_hook is the module machine name, notification is entity type, and Notification is the class implementing the entity you are trying to create.
function ost_hook_entity_create(EntityInterface $entity) {
  if ($entity-&gt;getEntityTypeId() == 'Deadline' || $entity-&gt;getEntityTypeId() == 'Message') {
    $new_entity = Notification::create([
      'title' =&gt; $entity-&gt;label() . &quot; notification&quot;,
      'field_content' =&gt; $entity-&gt;toLink()
    ]);
    $new_entity-&gt;save();
  }
}

Alternatively, you could use the following code.
function ost_hook_entity_create(EntityInterface $entity) {
  if ($entity-&gt;getEntityTypeId() == 'Deadline' || $entity-&gt;getEntityTypeId() == 'Message') {
    $new_entity = \Drupal::entityTypeManager()-&gt;getStorage('notification')-&gt;create([
      'title' =&gt; $entity-&gt;label() . &quot; notification&quot;,
      'field_content' =&gt; $entity-&gt;toLink()
    ]);
    $new_entity-&gt;save();
  }
}

If the file containing the hook is ost.module (as I suspect), the function implementing the hook is ost_entity_create(), not ost_hook_entity_create().
I used hook_entity_create() because the code needs to be executed for two different entity types. Using hook_ENTITY_TYPE_create(), I should  implement two hooks. (I assume that dealine and message are the entity machine names, in the same way the machine name for the Node entity is node.)
function ost_deadline_create(EntityInterface $entity) {
  $new_entity = \Drupal::entityTypeManager()-&gt;getStorage('notification')-&gt;create([
    'title' =&gt; $entity-&gt;label() . &quot; notification&quot;,
    'field_content' =&gt; $entity-&gt;toLink()
  ]);
  $new_entity-&gt;save();
}

function ost_message_create(EntityInterface $entity) {
  $new_entity = \Drupal::entityTypeManager()-&gt;getStorage('notification')-&gt;create([
    'title' =&gt; $entity-&gt;label() . &quot; notification&quot;,
    'field_content' =&gt; $entity-&gt;toLink()
  ]);
  $new_entity-&gt;save();
}

As side note, functions implemented from a module should always be prefixed by the module machine name. A module shouldn't have a createNotification() function, which should instead be called ost_create_notification() (assuming that ost is the module machine name).