  H$_2$CO is a small organic molecule widely detected in protoplanetary disks.
As a precursor to grain-surface formation of CH$_3$OH, H$_2$CO is considered an
important precursor of O-bearing organic molecules that are locked in ices.
Still, since gas-phase reactions can also form H$_2$CO, there remains an open
question on the channels by which organics form in disks, and how much the
grain versus the gas pathways impact the overall organic reservoir. We present
spectrally and spatially resolved Atacama Large Millimeter/submillimeter Array
observations of several ortho- and para-H$_2$CO transitions toward the bright
protoplanetary disk around the Herbig Ae star HD 163296. We derive column
density, excitation temperature, and ortho-to-para ratio (OPR) radial profiles
for H$_2$CO, as well as disk-averaged values of $N_{\mathrm{T}}\sim4\times
10^{12}$ cm$^{-2}$, $T_{\mathrm{ex}}\sim20$ K, and $\mathrm{OPR}\sim2.7$,
respectively. We empirically determine the vertical structure of the emission,
finding vertical heights of $z/r\sim0.1$. From the profiles, we find a
relatively constant $\mathrm{OPR}\sim2.7$ with radius, but still consistent
with $3.0$ among the uncertainties, a secondary increase of $N_{\mathrm{T}}$ in
the outer disk, and low $T_{\mathrm{ex}}$ values that decrease with disk
radius. Our resulting radial, vertical, and OPR constraints suggest an
increased UV penetration beyond the dust millimeter edge, consistent with an
icy origin but also with cold gas-phase chemistry. This Herbig disk contrasts
previous results for the T Tauri disk, TW Hya, which had a larger contribution
from cold gas-phase chemistry. More observations of other sources are needed to
disentangle the dominant formation pathway of H$_2$CO in protoplanetary disks.
