Things have changed quite a bit - but during WWII, I believe that subs were primarily used to disrupting shipping lanes through killing surface ships.
Into the cold war, countries started putting missiles on subs, and then building hunter/killer subs to take out subs with missiles on them. But that's a post WWII development. Germany was really targeting shipping lanes and supply lines with their subs.
From what I've read (and I could be wrong), the Allies really used subs more for reconnaissance or sneaking people in and out of places in the European theater.
Germany didn't have much of a surface fleet that got very far from land - and close to land airplanes would've wrecked US subs.