Is an HNN extension of a virtually torsion-free group virtually torsion-free?
Yes, here's an example with an HNN over finite index subgroups as requested. It's based on constructing an amalgam of two f.g. virtually free groups, that has no proper finite index subgroups, using Burger-Mozes groups.
Fact (proved below): for every $n\ge 3$ there exists a non-torsion-free, virtually free group $G$ with a subgroup of finite index $H$, isomorphic to $F_n$, such that $G$ is normally generated by $H$.
By Burger-Mozes, there exists $n<m$ with two embeddings $u,v$ of $F_m$ as finite index subgroup of $F_n$, such that the resulting amalgam $A(u,v)$ of $F_n$ and $F_n$ over $F_m$ using the embeddings $u,v$ is simple. (D. Rataggi improved and made explicit the values, providing for instance $(n,m)=(9,81)$.)
Now use $G$ as in the fact, with $H$ free of rank $n$ as above. Identify $H$ to $F_n$ to deduce two embeddings $u',v'$ from $F_m\to H\subset G$. Consider the amalgam $A=A(u',v')$ (of $G$ and $G$ over $F_m$ using $u'$ and $v'$).
Claim: $A$ has no proper finite index subgroup. Proof: the finite residual contains the Burger-Mozes subgroup given as subamalgam of $F_n$ and $F_n$ over $F_m$, hence, since $F_n$ normally generates $G$, contains both amalgamated factors $G$, hence is all of $G$. (Since $A$ is not torsion-free, it follows that $A$ is not virtually torsion-free.)
Consider the HNN extension $B$ given by the pair of embeddings $u',v'$ of $F_m$ into $G$. Namely, this is $(\langle t\rangle\ast G)/R$, with $R$ normally generated by the $tu'(h)t^{-1}v'(h)^{-1}$ for $h\in F_m$. Then $B$ is also not virtually torsion-free (the quotient by its finite residual is $\mathbf{Z}$), since it contains the above amalgam.
Proof of the fact: it is enough to do it for $n=3$, yielding $H\le G$: in general just use the projection $G'=F_{n-3}\ast G\to G$ and define $H'$ as the inverse image of $H$.
Consider the virtually free group $G=\langle a,b:b^3=1\rangle$. Map it by $p$ onto the dihedral group $D_6$ mapping $a$ to an element of order 2 and $b$ to an element of order 3. Then the kernel $K$ of $p$ has index 6 and is free.
Now consider a subgroup $L$ of $G$ of index 3 containing $K$, this generating normally $G$. Since $L$ has a torsion-free subgroup of index 2, it has no element of order 3, and hence $L$ is free. Moreover $L$ has rank 3 (subfact below).$\square$
Subfact: the free group $L$ has rank 3. Proof: Note that $G$ also has a normal subgroup $N$ of index 3, free of rank $3=1+2$ (namely the kernel of the retraction from $G$ to $\langle b\rangle$ killing $a$, which is freely generated by $a$, $bab^{-1}$, $b^2ab^{-2}$). Since in a virtually free group all free subgroups of a given index have the same rank, we deduce that $L$ has rank 3.
It is easy to construct a counter-example when $H$ and $K$ are not of finite index in $G$.
Let $A$ be a finitely presented torsion-free group which is not residually finite (e.g., the Baumslag-Solitar group $BS(2,3)$). Since $A$ is not residually finite, its finite residual $$Res(A):=\bigcap_{L\leqslant A, |A:L|<\infty} L$$ must be non-trivial, so take some $a \in Res(A)$, $a \neq 1$.
Define $G=A \times \langle b \rangle_2 \cong A \times \mathbb{Z}/2\mathbb{Z}$. Then $G$ is finitely presented and virtually torsion-free. We now set $$\Gamma=\langle G,t \mid tat^{-1}=ab\rangle.$$
I claim that $\Gamma$ is not virtually torsion-free. Indeed, it is easy to see that $Res(A) \subseteq Res(\Gamma)$ as $A\leqslant \Gamma$, so $a \in Res(\Gamma)$ and $tat^{-1}=ab \in Res(\Gamma)$, since the finite residual is a normal subgroup. Hence $b=a^{-1}(ab) \in Res(\Gamma)$, i.e., the element $b$, of order $2$, belongs to every finite index subgroup of $\Gamma$.
In the above example the associated subgroups $H$ and $K$ are infinite cyclic. I think that it should be possible to produce an example with $H$ and $K$ of finite index, but a different approach would have to be used.
On the positive side, the following two conditions together are sufficient to ensure that the HNN-extension $\Gamma$ is virtually torsion-free:
- Suppose that the base group $G$ has finitely many conjugacy classes of finite order elements (this would yield the same property for $\Gamma$);
- Suppose that $\Gamma$ is residually finite (then it has a finite index normal subgroup $N$ which avoids the finitely many conjugacy class representatives of torsion elements in $\Gamma$, hence $N$ must be torsion-free).