Under English law, a bank has a general right to combine accounts where a customer has multiple accounts with the same bank.  The right has been recognised since at least 1860 (and probably longer).  However it was not until 1975 in the House of Lords decision in National Westminster Bank Ltd v Halesowen Presswork & Assemblies Ltd [1972] AC 785 that it was finally determined that this was a type of set-off right rather than anything related to the banker's lien (a separate common law right).  Typically the right will be exercised where one account is overdrawn and the other is in credit so that the bank can secure full repayment of overdraft without the need to take any further action with respect to the customer.  The broad rationale is that separate numbered accounts are set up for administrative convenience only, but the legal duty upon a bank to "account" to its customers for the sums held by it only extends to the net sum.

Mutuality

In order for the bank to combine accounts there must be mutuality, i.e. it must be the same customer and the same legal entity for the bank.  However, accounts held at different branches of the same bank may still be combined.  Although it has not been finally determined by case law, most commentators accept that accounts in different currencies may be combined, as may accounts in different countries (so long as the governing law in each country permits such combination).

Bars to combining accounts
There are various grounds set out in the case law which indicate when an account may not be combined.
 Agreement to forbear.  An agreement by the bank not to combine accounts will be binding, possible even in the absence of any consideration.  If not an express time, then it will generally be implied that a material change in circumstances would terminate such an agreement (in Halesowen it was held that calling a meeting of creditors would constitute such circumstances, but in Australia it has been held that appointing a receiver did not.  
 Money held for specific purpose.  In line with the authorities on Quistclose trusts, if money is held by the bank for a specific purpose, then it is impressed by a trust and is not subject to combination.
 Money held on trust.  Where the customer holds the money in the account as trustee and so is not beneficially entitled to it, it cannot be combined.  However, it appears that the reverse is not true - if a trust account is overdrawn then the bank can combine that with a trustee's personal account because the trustee is personally liable for the obligations of the trust.
 Where account is subject to a security interest.  Provided the security interest is fixed and not floating, this will prevent combination of accounts.
 Where one account is a loan account.  This is considered further below.

Loan accounts
There is a distinct line of authority which indicates that where one of the accounts is a loan account then the bank cannot exercise its rights to combine accounts (Obed Tashabya v DFCU Bank).  Most of the authorities relating to this are older cases, but the rule was applied more recently in Fraser v Oystertec plc [2006] 1 BCLC 491.

Although slightly anachronistic, the rationale appears to be that the customer of the bank should not be at risk of the bank combining a short-term current account on which the customer writes cheques for daily expenses with a long-term loan account which is not due for repayment until some future time.  In practice, most loan agreements will usually give the bank a contractual right to set-off in any event.

Notice
Although there is one case which argues to the contrary, the orthodox position is that the bank does not need to give the customer notice prior to exercising a right to combine accounts.

Insolvency
If the bank does not exercise a right to combine accounts prior to a company going into insolvent liquidation, then insolvency set-off will operate automatically, and the insolvency set-off rules will prevail over the bank's right to combine accounts.

Foreign countries
The banker's right to combine accounts has been recognised at appellate level by the courts of various other common law jurisdictions, including Australia, Canada, Guyana and Singapore.  However, there does not appear to be any corresponding general right in civil law jurisdictions outside of the conventional right of set-off.

External links

 A banker's right to set off money

Footnotes

United Kingdom business law
Bank account
NatWest Group litigation