The U.S. Department of Homeland Security (DHS) has been using B-52s to check out suspicious merchant ships approaching North America, often when the ships are still about 2,000 kilometers from the coast. The B-52s use their targeting pods to take pictures of the ship, and transmit those back to DHS. A B-52 can do this while taking part in a training exercise. B-52s have a lot of jobs to do over the oceans.
This is largely because maritime reconnaissance has been revolutionized with the introduction, and combining, of lightweight search radars and targeting pods. With the targeting pod, you can stay high (20,000 feet) and far away (over twenty kilometers) and still get a close look. Thus a B-52 with a targeting pod is an excellent naval reconnaissance aircraft.
B-52's also practice dropping naval mines. This is something the air force has been doing since World War II, and with great success. The current air force naval mine is the Mk-62 "Quickstrike." This is basically a 500 pound bomb, with a sensor package attached to the rear. There are three different sensor packages, each providing a different set of sensors to detonate the mine. The Mk-62 is a "bottom mine," which is dropped in shallow water, and then detects a ship passing above using pressure (of the ship on the water), magnetism (of the metal in the ship's hull), or vibration. The sensor also comes with a computer, to enable the mine to follow certain instructions (like only detonate for ships that meet a certain criteria.)
The B-52 drops the mines at an altitude of about 1,000 feet, while moving at 500-600 kilometers an hour. The mines are usually dropped in known shipping lanes, especially those that serve as approaches to a major port. During World War II, air dropped mines proved devastating to Japanese shipping. Same thing with their use against North Vietnam during the Vietnam war.
The B-52s are also equipped to use Harpoon anti-ship missiles. Together, these two systems make the B-52 a lethal naval weapon. The F-18, B-2, B-1B and P-3C can also deliver naval mines.