Well, at the start of the war, your submarine is equiped with only hydrophones. This is a passive device that allows you to track surface ships by the noises from their engines and propellors. Later on in the war you can get the S-Gerat(SONAR) put on your boat. This is an active device that allows for a fairly accurate distance and bearing measurement. Finally, there will be the Balkan Gerat, which combines both the passive and active systems into one device. Hydrophones are best, because being passive, they don't give away your position. Active systems (SONAR/ASDIC) give more accurate data, but let the enemy destroyers know where you are.
Firstly, acquiring a target. you can do this manually or leave it up to your sonar operator. I find it best to do manually, as the sonar operator tends to miss the very distant contacts. Hydrophones and SONAR only work underwater, so you need to submerge the submarine. Historically, 30 meters was considered the best depth to listen at. However this does not seem to be modelled inSHIII, so periscope depth works nicely. It's easiest to hear a ship when your submarine is stopped, so stop the sub and listen. NOTE! You don't have to stop the ship, but your own propellor noise and the water flowing over the hydophones make it harder to hear other noises clearly. The further away a contact is the fainter the sound, so you have to listen closely. The pattern I follow is to move on the surface for an hour or two, the dive, stop and listen for 5-10 minutes, surface and repeat. Sooner or later you'll hear something. NOTE! Warships have faster turning propellors than merchants so if you hear a fast propellor beat, its a good bet you found a warship. Once you have found a target, note the bearing of the hydrophones, surface and head in that direction. I usually chase after a contact at full or flank speed. After about 15 minutes, I dive, stop ship get a new bearing to target surface again and head of in the new direction. NOTE! If the contact is very faint, I usually chase on the surface for 30 minutes to an hour. Eventually your sonar man will acquire the contact by himself. He'll give the bearing and approximate speed(slow, medium, fast). Sounds like you've already seen this, a black or red line, that shows the bearing to your target and where the line terminates is approximately where the ship is.
Tracking a target. Once you get the black or red line, stay submerged and stop or move at slow speed. You'll notice the line moves. Use the Marker from the toolbar to place Xs where this line ends. After 4 or 5 Xs, use the ruler to draw a line through them. This is your target's track or general direction of movement. Now, surface and move at flank speed to get in front of him, but don't let him see you or you will spook him. To do this move parallel to the track you have established. So as not to be seen by your target, this distance varies due to weather conditions, as well as if it is night or day. During the day, I try to stay about 7000-8000 meters from the target and at night 3000-4000 meters. Fog and rain will reduce this distance(but you'll be able to judge for yourself once you get some experience with this). If you lose sight of the target, submerge every so often to check his position and to see where he is in relation to you. Once you have gotten ahead of him, start adjusting your course to intercept his. When you are well enough ahead of him, turn so you are moving perpendicular(your approaching his track at 90 degrees, like a T) to his intended track. When you get within 2500-1500 meters dive to periscope depth, wait for him to come to you, use the periscope to observe your target and shoot when you get a good solution.
Like I said earlier, with time and experience you will develope you own meathods for tracking a target.
Some websites for historical information:
http://www.uboat.net/articles/id/52
http://www.fleetsubmarine.com/sonar.html