How to test whether E[X]>E[Y] controlling for Z? Question in mathematical terms. 
Assume an observation consists of three continuous variables $X$, $Y$ and $Z$. The sample comprises a sufficiently large number of observations. I would like to check whether $[X]>[Y]$, i.e. on average X being larger than Y. However, the added complication is that I am worried about confounder $Z$ and therefore would like to control for it. How could I approach this problem statistically?
Problem explained using regression. 
Without an confounder $Z$, I think one could test whether $[X]>[Y]$ by fitting the regression model
$$Y_i=\beta_0+\beta_1X_i+\varepsilon_i$$
and checking whether $\beta_0$ is negative and significant. Just adding Z as control wouldn't work because it messes up the sign of $\beta_0$. I guess mean-centering $Z$ doesn't help either, because $\beta_0$ would remain unchanged. 
Context of question is causal inference.
In simple terms, I am facing the following problem. Participants are asked to choose a subset $S$ of items to maximise a certain complicated objective function. The optimal subset $S^*$ provided by a computer algorithm is also known. Each item has two properties; lets assume these here to be size and weight. I want to check whether the average size $X$ of items in the participants' subsets $S$ is lager than the average size $Y$ of items in the optimal subsets $S^*$. However, I want to make a causal inference. The problem is that the size and the weight are positively correlated with each other. Let $Z$ be the average weight of the items in the participants' subsets $S$. I want to say that the average size of items in the participants' subset $S$ is larger than the average size in the optimal subset $S^*$ BECAUSE participants look for larger items in terms of their size than optimal rather than look for heavier items when picking their subset $S$.
UPDATE: CONCLUSION.
It seems to be untestable. The reason is that in many cases one could show both $[X]>[Y]$ and $[X]<[Y]$ depending on how exactly one controls for Z (e.g. either picking a postive or negative coefficient, respectively), and there is no telling what is right. Obviously, a test which could produce contradictory results wouldn’t be a credible statistical test.
 A: In your case the "confounding" does not matter. Your within-subject / repeated measures data collection design comes in as a fortune. In your problem we define $W=X-Y$, so you are interested in testing $H_0: E(W) \le 0$. Your sample gives you this information. You can use a one-sided t-test to solve this problem.
There is also formally no causal problem. There would be a causal problem if you were interested in estimating $p(X|do(Y=y))$, for example, in which case you would need to integrate over $Z$ in order to arrive at the correct estimate: 
$$p(X|do(Y=y)) = \sum_Z p(X|y,Z)p(Z)$$
As you are interested in means this process would involve estimating $E(X|Y,Z)$ using regression (for example and under assumptions of e.g. linearity), make a prediction of expected outcome  $\hat{E}(X|y,z_i)$ for all $i$ observations in your sample, and then average across all estimates. 
However, in your case you are interested in the difference of the expectations of the marginal distributions of $X$ and $Y$, so that confounding is irrelevant.
Another causal inference problem emerges if we modify your data collection design to a 'between-subject' design, where for each subject you only observe $X$ or $Y$, so that $W$ cannot be computed for each observation from the data. Let $T=0$ indicate that $X$ is observed and $T=1$ that $Y$ is observed and let $U=TY+(1-T)X$ be the observed outcome. Furthermore, assume $T$ is statistically dependent on $Z$. If now you want to estimate $E(W)$ you face the classical causal inference problem discussed in observational epidemiological research where treatment assignment is dependent on observed confounders. Now we need to estimate
$$E(W) =E(U|do(T=1))-E(U|do(T=0)) \\ = \sum_Z [E(U|T=1, Z)-E(U|T=0, Z)] p(Z)$$
which then could be estimated in similar fashion as discussed above. However in your case this scenario does not apply; I merely make the case to show how your problem differs from one of the 'classical' causal inference problems (observed confounding / confounding by indication).
