Once upon a time, submarines were a major threat to the world's navies. They were hard to see, and could suddenly attack out of apparently nowhere, and disappear beneath the waves before retaliation was possible. So finding and destroying them became a very very big priority.
This is less a priority now, because all the modern enemies of the United States are insurgent groups that cannot afford submarines, and would have no use for them if they had them.
But back to the original topic, how do you find something that spends most of its time underwater, is painted the same color as the ocean, and is designed to be as hard as possible to see? Well, look into its characteristics. First, some past solutions:
Submarines might be painted ocean colors, but they're still metal. When they're on the surface, and before nuclear and aqua-lung technology that was rather frequent. (Diesel powered engine needs fresh oxygen and smoke disposal, plus need to refresh the air so the crew doesn't, you know, suffocate), shine a bright light from an airplane. If it hits a sub, it reflects, and then you know where to shoot.
This is only really effective when the sub is near the surface. A deep sub is obscured by the water, which absorbs light with depth.
Sound bounces. Bats learn where everything is by emitting a high pitched sound that bounces off of things, and notices where things are by the reflections. Bats use this to find bugs. Anti-submarine people run sound through the ocean, which bounces off rocks and subs, and they tend to be subtly different. Once you've seen it, or rather, heard it, depth charges away.
This is only effective when the submarine is below the surface. A surfaced submarine is indistinguishable from, say, a whale, or a glob of seaweed.
* Sea microphone
Submarines aren't completely silent. They move by propeller, which makes noise. They attack with torpedos, which makes a noise when launched, and while moving. They require electric power, and back in the diesel age, that made quite a lot of noise. (Nuclear reactors are nearly silent.) Various life support machines make noise too.
Submarines usually detect each other by listening to the sea. Experienced sound operators can tell the difference between a submarine and a whale by sound alone.
Submarines are like ninjas -- their strength is that they attack very suddenly and without warning. So send ships out in groups, and when one of them is attacked by the submarine, the others attack the submarine, whose position has been revealed in the attack.
* Radio Snooping
Submarines communicate with their parent organization through two means: One is radio, and the other are specially built submarine-communication cables, by a shorter-distance radio. Radio can be tracked by triangulation. Snoop enough signals and one can be reasonable sure where the submarine is. At which point, depth charges ahoy.l
* Hunter Killers
Why wait for the submarines to come to you? Hunter killers are boats with many of the above technologies, who actively search for enemy submarines, and destroy them.
Submarines are made of metal, almost certainly steel. The movement of steel subtly warps the magnetic field of the earth. Keep a map of major ocean areas and their magnetic fields at all times. When something changes, it's a submarine. If you can't find records of it on any side friendly to you, it's depth charge time.
The parent organization of a submarine knows where it is at all times, mostly because it's the one issuing orders. Records must be kept. Have a spy steal these records. You now know where the submarine is.
* Possible other techniques
Navies around the world probably have other methods that they're not going to tell me. (After all, if your enemy discovers the nature of your technique, countermeasures can be developed.)
And to this list, I can suggest one other technique:
* Water Shadow Analysis
If you drag an object through the water, then let a seal into the area, they can use their whiskers to tell exactly what path the object took. If the object is one that interests them (because it's a toy, or contains fish), they'll almost assuredly make a beeline for it. However, their whiskers must be unobstructed to do this. A seal wearing a mask is not able to detect water shadows.
So, submarines must also make water shadows as they move. If you know where the submarine has ever been, and have water shadow detecting equipment, then you can follow it long enough to shoot it full of torpedos.