It is optimal to target weapons in FTL?

In the vast majority of cases, the enemy weapons room is your highest-priority target. If you can take out their weapons, the only threats they have left are their drones and teleporter, and those aren't usually enough to matter.

That said, taking down the enemy weapons and keeping them down can be pretty hard near the end of the game. It's often necessary to focus more on the enemy shields and cockpit in order to keep your damage output up, and treat the enemy weapons room as a secondary target. Late in the game it can be hard enough to penetrate the enemy defenses that you have to just focus on killing them and hope your own defenses are up to scratch.

I'd like to give an honorable mention to taking out the enemy medbay when you're using a boarding strategy - a successful boarding kills the enemy so quickly that the enemy weapons aren't likely to make much difference, and you usually don't want to be dealing hull damage to the enemy with your crew on board. (On the flip side, make sure you can fend off a pair of Mantis boarders, because unless you have a pre-igniter and focus-fire their teleporter, you're not going to outrace a boarding attack with lasers.)