Getting redirect to happen before header output

Your method is called too late. I don’t know how you call this method but you need to run it before output is sent to the browser– usually that means before get_header(). There are a number of hooks that can be used. For example (from https://wordpress.stackexchange.com/a/131210/21376):

add_action(
  'template_redirect',
  function() {
    if (is_single()) {
      wp_safe_redirect(home_url());
      exit;
    }
  }
);

Without more context, it is impossible to say exactly what the right hook is.