Suppose we have a 3D point $X=(x,y,z)$. Given the projection matrix of a camera:
$$ \begin{matrix} f_x & 0 & c_x\\ 0 & f_y & c_y\\ 0 & 0 & 1 \\ \end{matrix} $$
we can apply the projection transform on the point and get : $$X_c=(f_xx+c_xz,f_y+c_yz,z)$$ Then, dividing with the $z$ coordinate we end up with the 2D coordinates of the pixel $P$:
$$P=(\frac{f_xx}{z}+c_x,\frac{f_yy}{z}+c_y)$$.
Now the question:
Given that X projects to the central pixel $(p_x,p_y)$, I would like to find a rotation matrix $R$ which when applied to $X$ will cause $X$ to land on pixel $P'$$(p_x,p_y+a)$ after the projection.
$$X_w'=RX_w=(x_r,y_r,z_r)\\X_c'=(f_xx_r+c_xz_r,f_yy_r+c_yz_r,z_r)\\P'=(\frac{f_xx_r}{z_r}+c_x,\frac{f_yy_r}{z_r}+c_y)=(p_x,p_y+a)$$
I know the rotation is around the x axis so things simplify a bit :
$P'=(p_x,\frac{f_yy_r}{z_r}+c_y)=(p_x,p_y+a)$
We are essentially looking for the angle of rotation around the x axis.
If $p_y = f_y \tfrac{y}{z}+c_y$ and $p_y + a = f_y \tfrac{y_r}{z_r}+c_y$ then you are trying to solve the following equation
$$ \frac{a}{f_y} + \frac{y}{z} = \frac{y_r}{z_r} \tag{1}$$
Now a general x-axis rotation gives us $$(x_r = x, y_r = y \cos \theta - z \sin \theta, z_r = y \sin \theta + z \cos \theta)$$
With some re-arranging of (1) you have
$$ a z^2 \cos \theta + \left( f_y (y^2+z^2) + a y z \right) \sin \theta = 0 \tag{2}$$
Or
$$ \boxed{ \theta =- {\rm atan}\left( \frac{a z^2}{ f_y (y^2+z^2) + a y z} \right) }$$