In the TV show as well as in the Star Trek movies, photon torpedoes don't seem to have a warp drive. So wouldn't it be easy for a ship to just go to warp and get out of the way?
Generally speaking, though it's never very clear in Star Trek, there are a few things that would prevent that from being a useful strategy in general. First, photon torpedoes are warp capable. So jumping to warp doesn't guarantee that you can outrun them. Second, they are guided weapons that can change course to follow a target ship within the limits of its design. And finally, it takes several seconds to power up and engage a warp drive. The speed of a photon torpedo can usually close the distance before the power-up cycle has completed.
So, while there are probably occasions where that strategy would work, it's far from an effective strategy in most cases.
This happens in Star Trek V: The Final Frontier.
Kirk and his landing party have been taken hostage by Spock's half-brother Sybok, who forces them to return to the Enterprise on the Galileo shuttlecraft. Unfortunately, the Klingons seize this precise moment to attack, and fire a photon torpedo just as the shuttle crashlands in the shuttlebay. Acting Captain Chekhov orders "Warp speed now!" and Enterprise goes to warp just in time to dodge the incoming torpedo.
On the surface, a Picard Maneuver would possibly work. http://en.memory-alpha.org/wiki/Picard_Maneuver.
Photon torpedoes don't actually reach warp speed, giving more credence to being able to simply get out of the way. Additionally, photon torpedos have had a wide variance in capabilities - sometimes being smart and locking on, other times missing because the target simply adjusted it's course.
Deep Space Nine technical manual:
Also included in the torpedo are target acquisition, guidance and detonation assemblies and a warp sustainer unit. The latter is charged by the launching vessels own drive field at launch, boosting the torpedo speed up to Vmax = Vl + (0.75 Vl / c), where Vl is the velocity of the launching vessel. If launched at low impulse flight the torpedo will accelerate to a 75% higher sublight velocity; launch at high impulse speed will not push the torpedo into warp. If launched during warp flight the torpedo will continue at warp until the sustainer is exhausted. Torpedo range can be extended by utilizing the matter / antimatter warhead to power the sustainer, although this causes a corresponding loss of warhead yield.1 For a mid-range yield the torpedo can achieve ranges of some 3,500,000 kilometres at sublight speeds.
Now, although torpedoes have acquisition and guidance, how would this be maintained when the target essentially ceases to exist when it drops into subspace (even if just momentarily)?
So in this case, you would have to make a leap of faith, that based on technologies, the photon torpedo is smart and can maintain the characteristics of it's target and recognize when the target appears back in physical space. While plausible, I'm not aware of any evidence of this.
So, it's possible that a Picard Maneuver work work gangbusters, but unfortunately due to a lot of the holes in the physics of the Star Trek universe that have been hobbled together over the years, it's really hard to make a determination.
When you're at battle, escaping isn't an option when you have confidence to beat enemy ship. Remember, few photon torpedoes aren't a big deal when your shields are up.
In critical situations, when one photon torpedo hit can do critical damage, it can be dramatically seen that they already fight to have fully working warp capability. :)
You can escape a photon torpedo by warping (in fact, I have seen it in canon.. not in mind 'when'), but only if firing vessel is at sub-light speed. A photon torpedo doesn't have warp drive, so it can't go FTL by own, but it has warp field sustainability. Means, a vessel pursuing you at warp speed can fire photon torpedoes having warp speed. Due to warp field sustainability, the photon torpedo won't drop to sub-light speed. And, it'll hit you even if you're at warp speed. You can see it in Star Trek: Enterprise TV series as well as Star Trek into Darkness movie.
Simple answer is -- it takes too long to prep for.
In Star Trek V: The Final Frontier -- a film which made a lot of people angry and has been widely regarded as a bad move -- Chekov does avoid a Bird of Prey's attack by going to warp just after Kirk and the Gang land the shuttlecraft in the Enterprise-A. Nothing in this movie should be taken very seriously, but 'it happened'.
Another example of extreme prep time is the TNG episode Peak Performance; the Hathaway was already preparing to surprise the Enterprise-D with a sudden warp jump that was most likely going to stall the ship's engines; it ends up being used to confuse some opportunistic Ferengi into thinking that the Enterprise has destroyed the Hathaway to prevent the Ferengi from acquiring the valuable contents of said ship (which it never had in the first place). It required extensive planning and preparedness on the part of the Hathaway to even get the engines to a place where this would work, let alone warp at the calculated time in the right direction, but again they had time to actually lay in the coordinates for a 'safe' warp vector.
In a combat situation there are likely too many variables to consider to safely escape via warp speed; proximity to other ships, line-of-sight clearance, ambient effects that may futz with the ability to form a warp shell, etc. For example, we know from the episode Yesterday's Enterprise that an extreme exchange of torpedos has ripped Magic Holes in spacetime which lead to amazing episodes of TNG; it is possible, though I don't believe verifiable, that in general if there have been several warp fields skimming around the local area that forming a new one is either risky or difficult.
From the accusations and evidence of the episode Force of Nature, at the time of Enterprise-D's tour there was such a thing as "too much warp speed" for one area of space to handle; perhaps it is so that there is a correlation between the damage in Force of Nature, the torpedo-induced temporal disturbance in Yesterday's Enterprise, and other situations wherein warp fields can't be maintained because 'the script says the Easy Button is offline, Captain'.
That's a lot of extrapolation, but if it were my job to explain why smaller craft don't just spend time warping around bigger ships avoiding crossfire, that's probably what I'd go with :)
I think the answer is more around story telling. If you read memoirs about the authors, there was a rule that they could not use the transporter to solve everything. If you think about it, most problems could have been solved in a minute's time just by beaming someone into space or out of harm's way, or even beaming some small thing out of someone's body.
Anyway, I think warp drive is likely the same thing. Because the ship is going so fast and because they could calculate a path so quickly. And because all they would need to do is keep the engines warm. They could make it work. Oh, we all know they could make it work.
I imagine, if you ask the writers, you would get a consensus that they didn't solve too many problems with warp drive because it would cheat the overall story telling part of Star Trek. A similar question would be, why did they always target engines and weapons, when a quick shot to the bridge would disable any opponent's ship instantly and permanently. :)
This answer is speculation, I know.