Photochemical smog forms when nitrogen oxides (NO$_x$) and hydrocarbons (volatile organic compounds) react in the presence of sunlight.
These reactions produce ozone and other photochemical oxidants.
Hence,
\[
\boxed{\text{Sunlight, NO}_x\text{ and hydrocarbons}}
\]
is the correct answer.
Therefore,
\[
\boxed{(B)}
\]