Woocommerce remove bank account number on order thank you page

You could try to use conditional is_page('checkout') or is_checkout(), first.

Then you can use remove_action() for removing your hooked function from checkout page only…

This way you don't have to edit templates.

---- Update ----

USING CSS:
You can also use CSS to hide just account number targeting one of this selectors/classes. For example, in one of my e-commerce, this are the css selectors to target:

  • .woocommerce-checkout ul.order_details.bacs_details
  • .woocommerce-checkout ul.order_details.bacs_details > li.iban
  • .woocommerce-checkout ul.order_details.bacs_details > li.bic

With: display:none;

---- update2 ----

Using your hook with a conditional:

1). Inside:

add_action('woocommerce_before_template_part', 'thankyou_bacs');
function thankyou_bacs() {
    if(is_checkout()){
        /* get bacs payment gateway class */
        $methods = WC()->payment_gateways->payment_gateways();
        $bacs_class = $methods['bacs'];
        unset($bacs_class->account_details[0]['account_name']);
        unset($bacs_class->account_details[0]['account_number']);
    }
}

2). Outside:

if(is_checkout()){
    add_action('woocommerce_before_template_part', 'thankyou_bacs');
    function thankyou_bacs() {
        /* get bacs payment gateway class */
        $methods = WC()->payment_gateways->payment_gateways();
        $bacs_class = $methods['bacs'];
        unset($bacs_class->account_details[0]['account_name']);
        unset($bacs_class->account_details[0]['account_number']);
    }
}