How does sodium bicarbonate act as a deodorizing agent?
The key factor is that baking soda is amphoteric. This means that it can react both with strong acids and with strong bases which are typically smelly compounds (sour milk, rotten fish, fatty acids in sweat).

The explanation on the third page of article by Lamb [1] gives a nice summary:


  The chemical explanation of why bicarbonate of soda should act as a deodorant
  is of interest. Sweat (3) has an acid reaction, $\ce{pH}$ of $5.2\text{–}6.75$ which is due to the fatty acids or acid phosphates of sodium and potassium which it contains. It also contains $\ce{NaCl}$, $\ce{KCl}$, alkaline salts, organic acids and urea. Minute amounts of unstable fats and oils are secreted in sweat and hydrolysed to their corresponding fatty acids and glycerin. Free fatty acids may be secreted. Many of these acids are volatile and have a characteristic disagreeable odor. These include butyric acid, formic acid, caproic acid and valerie acid. The following are among the possible explanations of the manner in which sodium bicarbonate acts as a deodorant in the axilla.
  
  
  It forms a sodium salt with butyric, caproic and valerie acids. These sodium salts are comparatively mild in odor in comparison to the volatile "rancid-smelling" fatty acids.
  By changing the $\ce{pH}$ of the axillae, the bacteria which decompose the fats are unable to act. However, as a result of this the staphylococcic flora which prefer higher alkalinity might thrive and axillary furunculosis might result.
  


To give an example. The reaction of baking soda with butyric acid looks like this:

$$\ce{C3H7COOH + NaHCO3 -&gt; C3H7COONa +H2O + CO2} $$

while butyric acid is extremely smelly (an intense vomit smell), the salt hardly smells at all.

Given this explanation, I think $\ce{NaOH}$ should obviously also work well for deodorizing in case the smell is caused by acids. The problem would be that smells caused by basic compounds are left untouched.

References


Lamb, J. H. Sodium Bicarbonate: An Excellent Deodorant. Journal of Investigative Dermatology 1946, 7 (3), 131–133. https://doi.org/10.1038/jid.1946.13