The TDC just programs the torpedoes before they are fired. Once they leave the tubes they are on their own. So feel free to break a lock once you've fired.
You can even break it earlier if you're setting the TDC things by hand via a mod or using the default 1-2-3 bubble system.
If you're attacking a convoy you can even do the trick where you use the same settings for all ships in a row and just fire as each pass your scope and they'll all hit at the same time!
This post explains that process.