If the initial capital is $1$ unit of wealth and the fraction bet is $f$, then the capital after betting on the coin toss is
$$W_1 = 1 + f\xi$$
where $\xi$ is a binary random variable. Assuming a fair coin and WLOG $x,y > 0$ enumerated in wealth units , we have $$P(\xi = x) = P(\xi = -y) = 1/2$$
The expected capital is
$$E(W_1) = E(1 + f\xi) = 1+ f(x-y)/2$$
If $x >y$, you have an edge and the optimal fraction is $f^* = 1$ to maximize expected capital. However, if you are risk-averse you might not play to avoid a $50 \%$ chance of losing $y$.
A utility function is a construct that assigns preferences to random outcomes (gains and losses). Specifically log utility was introduced by Bernoulli to resolve the St. Petersburg paradox
The optimal fraction with log utility is obtained by maximizing
$$E( \log W_1) = \frac{1}{2} \log(1 + fx) + \frac{1}{2} \log (1 - fy)$$
subject to the constraint $0 \leqslant f \leqslant 1$.