Why does this reaction produce an alcohol in one case and an alkene in the other?
Please also see Why substitution and elimination reactions are favored respectively at lower and higher temperature?
The reaction conditions are the clue you are looking for.

The first thing to recognize is that in any situation where there is competition between substitution and elimination, you will always get a mixture of products.  The question is, which one will dominate.

The effect of temperature is subtle, and sometimes misleading. In practice, organic chemists heat many (maybe even most) reactions, in order to get them to occur in a reasonable timeframe.  When we are teaching about the effect of temperature on the competition between substitution and elimination, we often indicate heating ($\Delta$) is present for the elimination and not the substitution.  You should take this to mean that higher temperature favours elimination.

Now, subtleties aside, let's look at why heating favours elimination.




One difference between the two situations is the relative changes in entropy.  We can see that in the case of elimination, the overall entropy of the system is increased after the reaction (there are more different particles) while in the case of substitution, the entropy change is negligible.

We can consider the competition between the two reaction pathways like this:

$\Delta G_{S_N2} = \Delta H_{S_N2} - T\Delta S_{S_N2}$ 

and

$\Delta G_{E2} = \Delta H_{E2} - T\Delta S_{E2}$

At low temperature, the enthalpy term ($\Delta H$) dominates, while at higher temperature, the entropy term ($\Delta S$) dominates. 

Therefore, the increase in temperature favours the reaction with the larger entropy contribution.