It is always the same $24$, and it is all over the place. I'm sure this number has some deeper origin, but I usually associate it to the fact that $\mathrm{SL}_2\mathbb Z=\mathbb Z_4*_{\mathbb Z_2}\mathbb Z_6$ (read, the modular group is the amalgamated product of these cyclic groups along $\mathbb Z_2$). We see that $4\times 6=24$, which shows up everywhere when studying 2d stuff (in particular, the torus, whose mapping class group is the modular group above). It probably also has something to do with the E8 and Leech lattices (with rank $8$ and $24$, respectively). Also, recall that String Theory is effectively a 2d CFT (and the torus is the first surface with a non-trivial topology). For other occurrences of the number 24 (or 12) in physics and mathematics see e.g. this talk by Baez (and this PSE post for an explicit computation). Finally, for another example that does not seem to be mentioned in the above references, let me note that anomalies are classified by generalised homology theories in one higher dimension, and we have $\Omega_3^\mathrm{fr}=\mathbb Z_{24}$, again the same integer (this is the cobordism group of framed 3-manifolds; the framing anomaly in 3d is the same thing as the chiral anomaly in 2d).
But anyway, the quick-and-dirty way to find this number is to use zeta-regularisation:
$$
\sum_{n=1}^\infty n\sim \zeta(-1)=-\frac{1}{12}
$$
This sum appears both when computing the Casimir force (cf. this PSE post), and the string critical dimension. In particular, the Casimir can be shown to be proportional to $F_D\propto \zeta(-D+1)$ (which becomes $\zeta(-1)$ in $D=2$), while the critical dimension of the bosonic string is found by insisting that the Virasoro central charge vanishes
$$
c\propto \frac{D-2}{2}\zeta(-1)+1\equiv 0
$$
from where $D=2-2/\zeta(-1)=26$ follows. We thus see that in both cases one is required to evaluate $\zeta(-1)$, which is $-1/12$. This is the "something" in Casimir that has to do with String Theory.
It is important to insist that these two phenomena are not in fact independent. As discussed by Tong (cf. ยง4.4.1), the central charge of a CFT is a Casimir force!