Hamilton-Jacobi formalism and on-shell actions My question is essentially how to extract the canonical momentum out of an on-shell action. 
The Hamilton-Jacobi formalism tells us that Hamilton's principal function is the on-shell action, which depends only on the coordinates $q$. Therefore, if $S$ refers to the off-shell action with Lagrangian $L$, a result for the canonical momentum is 
$$ \frac{\partial L}{\partial \dot q} = p = \frac{\partial S^\text{on-shell}}{\partial q} $$
In theory, when evaluating the on-shell action, one plugs in the EOM into $S$ and all that's left are boundary terms. If we illustrate this with the harmonic oscillator in 1D, one gets 
\begin{align} S^\text{on-shell} &= \int_{t_i}^{t_f} L dt \\
&= \frac{m}{2} \int_{t_i}^{t_f} \left( \dot q^2 - \omega^2 q^2 \right) dt\\
&= \frac{m}{2} \int_{t_i}^{t_f} \left( \frac{d}{dt} (q \dot q) - q \ddot q - \omega^2 q^2 \right) \\
&= \frac{m}{2} \left[ q(t_f) \dot q(t_f) - q(t_i) \dot q(t_i) \right] \end{align}
Now, this depends on $\dot q$, whereas it should depend only on generalized coordinates. Also, the on-shell action depends on the boundary values of our coordinate $q$, so we can't differentiate w.r.t. $q(t)$ to get a conjugate momentum $p(t)$ for all times, like it is usually done in the Lagrangian formalism.
What am I not seeing?
 A: I) At least three different quantities in physics are customary called an action and denoted with the letter $S$:


*

*The off-shell action $S[q;t_i,t_f]$,

*The (Dirichlet) on-shell action $S(q_f,t_f;q_i,t_i)$, and

*Hamilton's principal function $S(q,\alpha, t).$
For their definitions and how they are related, see e.g. my Phys.SE answer here.  
II) OP's sought-for relations 
$$\tag{A}  p_f~=~\frac{\partial S}{\partial q_f}, \qquad   p_i~=~-\frac{\partial S}{\partial q_i}, $$
for the on-shell action are eq. (11) in my Phys.SE answer here, where a proof is also given.
III) For the Harmonic oscillator it is indeed true that
$$\tag{B} S(q_f,t_f;q_i,t_i)~=~\frac{ q_f p_f - q_i p_i }{2}, $$
with a half on the RHS, as OP mentions.
IV) Eqs.(A) and (B) are not inconsistent with each other even in the presence of the factor half, because the initial and final momentum $p_i=p_i(q_f,t_f;q_i,t_i)$ and $p_f=p_f(q_f,t_f;q_i,t_i)$ in eq. (B) depend on the value of the Dirichlet boundary conditions $q_i$ and $q_f$.
