The Bangor Publishing Co., owner of the Bangor Daily News, has signed an agreement to sell the company’s headquarters on Main Street to an affiliate of Ocean Properties.