A and B are non-zero since $0\in\mathbb{Q}$. This is the only point at which I'm going to use $A,B\notin \mathbb{Q}$, so that condition could be replaced by $A,B\neq 0$. (The given equation reduces to $f(x)=f(x)$ if $A=0$ or $B=0$, so in that case any $f$ would do.) Also $A+B$ must be non-zero since otherwise the given equation is not defined.
For each $x$ and $y$ the given equation determines $f$ to be linear for one particular linear combination of $x$ and $y$ with the proportions $A/(A+B)$ and $B/(A+B)$. If $A$ and $B$ have the same sign, this is a convex combination. If $A$ and $B$ have opposite signs, write
$z=\frac{Ax+By}{A+B}$
and
$f(z)=\frac{Af(x)+Bf(y)}{A+B}$
and solve for $x$ and $f(x)$:
$x=\frac{(A+B)z-By}{A}\;,$
$f(x)=\frac{(A+B)f(z)-Bf(y)}{A}\;.$
If $A+B$ and $-B$ have the same sign, this is a convex combination with the proportions $(A+B)/A$ and $-B/A$. If not, then $A+B$ and $-A$ have the same sign, so we can do the same thing solving for $y$ instead of $x$.
Thus, in any case the given condition fixes $f$ to be linear for a particular convex combination of any pair of arguments. Denote by $g$ the function that maps a pair of points to this convex combination and by $S$ the closure of $\partial D^n$ under $g$, i.e. the set of all points that can be reached in a finite number of steps by starting with all points on the boundary of the cube and in each step adding the given convex combination for each pair of points reached so far. Then there exists a non-zero $f$ iff $S\neq D^n$, since $f$ has to be zero on $S$ and we can choose $f$ to be any linear function on $D^n\backslash S$.
If $n=1$, $S$ is countable and $D^1$ is uncountable, so $S\neq D^n$.
For $n>1$, for given w in the interior of $D^n$ each line through $w$ has two intersections with $\partial D^n$. Choose some continuous family of lines through $w$ such that the proportion at which $w$ lies between these intersections varies across the family. For each line, $S$ contains at least the closure of the set of the two intersections under $g$. The points in that closure lie at the same proportions between the intersections for each line, and these proportions form a (countable) dense subset $P$ of $[0,1]$. Now as the line is continuously varied in the continuous family of lines, the proportion at which $w$ lies on the line varies continuously, and hence sweeps through elements of $P$. Thus $w\in S$, and hence $S=D^n$.
In summary, for arbitrary $A$ and $B$ there is a non-zero $f$ satisfying the given equation iff $n=1$.
Note that I didn't use the boundedness condition.