Bank of America Corp. has agreed to pay $335 million to settle allegations that its Countrywide Financial Corp. unit discriminated against minority homebuyers, the U.S. Department of Justice announced Wednesday. It's the largest residential fair-lending settlement in history.