$\newcommand{\ZZ}{\mathbb{Z}}$The following example shows that the implication "$H$ virtually $\ZZ$ implies $H$ equals $\ZZ \rtimes K$ or $K \rtimes \ZZ$." does not hold.
$\newcommand{\Aut}{\operatorname{Aut}}$$\newcommand{\Ends}{\operatorname{Ends}}$First, let $H$ be any virtually $\ZZ$ group. Then $H$ has exactly two metric ends. There is a homomorphism $H \to \Aut(\Ends(H)) \cong \ZZ_2$, given by the action of $H$ on itself via conjugation. We'll use this repeatedly.
Let $\ZZ_3 = \langle u \rangle$ be the cyclic group of order three and let $\phi \in \Aut(\ZZ_3)$ be the non-trivial element. Note $\phi^2$ is equal to the identity. Write $\ZZ = \langle t \rangle$. Form the semidirect product $G = \ZZ_3 \rtimes_\phi \ZZ$.
Now, let $\rho$ be the nontrivial involution of $\ZZ$. That is, $\rho(t) = t^{-1}$. If we take $\rho$ to act trivially on $\ZZ_3$ then it is a short computation to show that $\rho$ now is an automorphism of $G$.
So we write $\ZZ_2 = \langle w \rangle$ and we form the group $H = G \rtimes_\rho \ZZ_2 = (\ZZ_3 \rtimes \ZZ) \rtimes \ZZ_2$. Thus $H$ is virtually $G$, and so it is virtually $\ZZ$.
Note that $w \in H$ swaps ends of $H$ while $u$ preserves the ends of $H$.
Case 1
Note that no element of $K \rtimes \ZZ$ swaps the ends of the group. Thus $H$ is not isomorphic to a group of the form $K \rtimes \ZZ$.
Case 2
Now suppose that $H \cong \ZZ \rtimes K$. Since $H$ is virtually $\ZZ$, it must be that $K$ is finite. Let $s$ be the generator of the normal subgroup of $\ZZ \rtimes K$. Consider any $s^\ell k \in \ZZ \rtimes K$. Suppose that $k$ doesn't swap ends. Thus $ksk^{-1} = s$ and we find that $\ell \neq 0$ iff $s^\ell k$ has infinite order. If $k$ does swap ends (ie $ksk^{-1} = s^{-1}$) then $(s^\ell k)^2 = k^2$ is finite order and $(s^\ell k)^3 = s^\ell k^3$ is the trivial element implies that $\ell = 0$.
So let $k \in K$ be the image of $u \in \ZZ_3 < H$. Since $u$ doesn't swap ends, neither does $k$. Let $s^\ell h$ be the image of $t$. By the above, $h$ doesn't swap ends. We compute: $tut^{-1} = u^{-1}$ thus $s^\ell h k h^{-1} s^{-\ell} = hkh^{-1} = k^{-1}$. That is, there is a finite order element of $H$ that
- conjugates $u$ to its inverse and
- doesn't swap ends.
Using the normal forms for elements of $H$ we can check that this is not the case, and so have arrived at a contradiction. $\square$
I think that this is almost as bad as things can get. If $H$ is now any group that is virtually $\ZZ$ then the kernel of the map $H \to \Aut(\Ends(H))$, ie the "end preserving subgroup", always has index at most two. This kernel can, in turn, be written as $F \rtimes \ZZ$, where $F$ is the kernel of the map "$g$ goes to its average translation distance". The only remaining nasty bit is that the map from $H$ to $\Aut(\Ends(H))$ doesn't have to split...
EDIT - Following Professor Holt's good example, here is a presentation of my counterexample group $H$:
$H = \langle u, t, w \mid u^3 = w^2 = 1, \, wtw^{-1} = t^{-1}, \, tut^{-1} = u^{-1}, \, wu = uw \rangle.$