"I particularly get stuck how to determine when a function is onto especially when the function is given as a mathematical expression."
As well you should as the codomain is not stated. It's impossible to state if the function is onto if the codomain is not stated.
The domain is $\mathbb R\setminus \{-\frac 12\}$ so if $f:\mathbb R\setminus \{-\frac 12\}\to \mathbb R$ this may or may not be onto. If $f:\mathbb R\setminus \{-\frac 12\}\to \mathbb C$ it most certain is not onto. ($f(x) = i$ has no solution) and if $f:\mathbb R\setminus \{-\frac 12\}\to f(\mathbb R\setminus \{-\frac 12\}) = \{f(x)|X\in \mathbb R\setminus \{-\frac 12\}\}$ must certainly is.
The unstated assumption is:
$f:\mathbb R\setminus \{-\frac 12\}\to \mathbb R$
and we need to prove/disprove for any $y \in \mathbb R$ that there exists one or more $x$ so that $f(x) = y$.
So if $\frac x{2x + 1} = y$ then $x = y*(2x+1)$ and...
$x = y*2x + y$
$x - 2yx = y$
$x(1-2y) = y$. If $1 - 2y\ne 0$ we have
$x = \frac {y}{1-2y}$ and so $f( \frac {y}{1-2y}) = y$ is possible so long as $\frac y{1-2y} \ne -\frac 12$.
i.e. if $2y = 2y - 1$ which would mean $0 = -1$ which is impossible.
So as long as $1-2y\ne 0$ then $x =\frac y{1-2y}$ is a solution to $f(x) = y$.
But what if $1-2y=0$ or $y=\frac 12$. Is it possible for
$\frac x{2x + 1} = \frac 12$? That would mean $2x = 2x + 1$ and that would mean $0 = 1$ which is impossible. So $f(x) = \frac 12$ has no solution. It is not onto if the codomain is $\mathbb R$.
However if $f:\mathbb R\setminus \{-\frac 12\}\to \mathbb R\setminus\{\frac 12\}=f(\mathbb R\setminus \{-\frac 12\})=\{f(x)|x \in \mathbb R\setminus \{-\frac 12\}\}$ then it is onto as for all $y\in \mathbb R; y \ne \frac 12$ then $\frac y{1- 2y}\in R\setminus \{-\frac 12\}$ and $f(\frac y{1-2y}) = y$
But it is conventional to assume the co-domain is, if not specified otherwise, is $\mathbb R$.
FWIS: All functions can be made onto by simply restricting them to the image of the function. That is to say $f: D \to f(D) = \{f(x)|x \in D\}$ is, by definition, onto. But it is conventional to assume the co-domains is $\mathbb R$ and not usually $f(D)$.