Is there a chemical reaction which could give off enough heat underwater to cook something?
Interesting prompt!
There are plenty of reactions which could be performed underwater to release a large amount of energy. In fact, many substances react vigorously with water itself. You may have heard about how alkali metals such as sodium are not compatible with water, and there's a good reason for it!
Explosive reactions aren't particularly suited to cooking food, though, and a sustained flame would be much more useful. Interestingly enough, there was legitimate research performed on making underwater flames, for a very specific purpose: the Olympic torch!
For the 2000 Summer Olympics in Australia, during the classic Olympic torch relay before the start of the games, the torch was actually carried ablaze underwater for three minutes at the Great Barrier Reef. According to Wikipedia, the usual fuel for the burning torch is a mixture of liquefied propane/butane, which burns using oxygen gas in the air as an oxidizer (more details of a torch's construction can be found here). There is very little dissolved oxygen in ocean water, however, so the fuel/oxidizer mixture had to be changed. From the BBC article:

The special flare was developed after nine months by a team of chemists and engineers at Melbourne pyrotechnics company Pains Wessex.
The company's managing director Charles Tegner said designing the torch was a challenge - not only to produce a flare to burn underwater at such a depth, but to burn like the Olympic torch flame as well.
&quot;It had to be clearly visible,&quot; he said. &quot;Such flares don't normally exist.&quot;
The flare's chemical composition, pressed into a steel tube, produces sufficient oxygen and nitrogen to maintain a very hot flame.
The flare burns so fiercely at more than 2,000 degrees Celsius that this creates enough pressure to keep the water from entering the tube.
Its intensity is produced by a mix of oxygen-generating chemicals as well as the combustible element magnesium in a finely powdered form

I haven't found the detailed composition of the fuel/oxidizer mixture, but this is already a very good hint. Magnesium is an alkali earth metal which burns vigorously with a bright white flame in many conditions, be it in pure oxygen, air, pure nitrogen, or even pure carbon dioxide, and it will also react with water when hot producing hydrogen gas, much like sodium (this is why reactive metal fires are so hazardous; don't even think about using a $\ce{CO2}$ or water extinguisher on them, that just feeds the fire!). In this case, the pyrotechnicians decided to mix finely pulverized magnesium metal with a solid oxidizer, very likely something such as potassium chlorate, $\ce{KClO3}$, which decomposes under heat releasing oxygen gas. The flame was lit in air until the reaction between the magnesium and solid oxidizer started going, and then it was safe to submerge the torch while the reactants lasted. The stunt has in fact been repeated since.
To add a few more options to this answer, there is a general class of reactions with water called hydrolysis reactions, some of which are quite energetic. Here, the starting material tears apart water molecules directly and uses the fragments to modify its structure to a more stable form. For example, this is what happens when phosphorous pentoxide is allowed to come into contact with water. This avidity for water makes phosphorous pentoxide a useful material in a laboratory, as it is capable of scavenging trace amounts of water from a liquid or gas. However, these types of reactions already tend to release much less energy per gram of reactant, compared to combustion reactions.
Lastly, I'll cite one more thing. Even without any chemical reaction, the dissolution of some solids in water is capable of releasing some heat. This happens when starting material has a weaker attraction to itself than to water molecules. This property can be exploited in disposable heat packs. These types of processes usually release even less heat per gram of starting material than combustion or hydrolysis, but at least the process is conceivably easily reversed, provided energy is given to dry the material again.
Therefore, it is possible to get a lot of heat from reactions underwater, though it is quite a more elaborate process than starting a fire in air.
Edit: Now that I saw the original question at Worldbuilding.SE, I realize part of it wondered about how cooking would be done in earlier stages of technological development. In this case, I'm hard-pressed to think of a chemical reaction which happens using materials found easily underwater and releases a lot of energy. The difficulty is great enough that it has actually been suggested previously as a general argument for why technologically advanced or even sentient life would be unlikely to develop underwater, as any hot thermal processing of food or materials would be severely hindered. Except for incredible strokes of luck, hydrothermal vents on the sea floor sound like the most reliable heat source which could be accessed by a primitive civilization.