I've heard people say it has something to do with anomalies in gauge theory. If that is correct, can someone please expand...
Be careful what you ask for. ;)
I'll try to convey some of the basic ideas, using intuition instead of mathematical rigor. To help keep the length of this post under control, I'll use boldface font for keywords that you can use to find more detailed information.
In this context, the word "anomaly" has a couple of different closely related meanings:
Quantization anomaly, usually just called anomaly and sometimes called quantum symmetry breaking, refers to the loss of a symmetry when a classical model is quantized to obtain a quantum model.
Given an already-quantum model with some kind of global symmetry, an 't Hooft anomaly is an obstruction to gauging the symmetry. I'll explain what this means below.
For a little more information about definition 1, I'll refer you to another question (which has a good answer):
The two definitions are related to each other, but I'll focus on definition 2, which has spawned lots of fruitful research over the past couple of decades. 't Hooft anomalies can be broadly classified into two types:
Perturbative (or local) anomalies. These anomalies can be detected using perturbation theory.
Nonperturbative (or global) anomalies. Anomalies in discrete symmetry groups are of this type: they don't have infinitesimal elements, so they can't be detected in perturbation theory.
QFT textbooks usually emphasize perturbative/local anomalies, because QFT textbooks usually revolve around perturbation theory. I'll focus on nonperturbative/global anomalies instead, because discrete groups are conceptually easier, and their anomalies still involve plenty of interesting topology. Topology enters the picture in at least three different ways, including the topology of spacetime itself and also the topology of gauge fields. Let's take it one step at a time...
As far as we can tell by direct observation, spacetime is topologically trivial. However, we have two good reasons to consider nontrivial topologies:
Effective QFT. One of the most interesting things about QFT is that its predictions at low energy can look very different than its structure at high energy. The classic example is quantum chromodynamics (QCD), which is defined in terms of quark and gluon fields, but those are only "visible" at sufficiently high energy. At lower energies, QCD correctly predicts that we should only see mesons and baryons. Understanding 't Hooft anomalies can help us understand which QFTs can arise as low-energy effective models of other QFTs, because the QFTs on both ends must have the same 't Hooft anomalies. This is a powerful constraint, and it becomes even more powerful when we consider the QFTs on spacetimes with nontrivial topology.
Quantum gravity. The usual concept of spacetime is believed to be merely an approximation that can break down when quantum gravity effects are important (cf the holographic principle), so any QFT that arises as a low-energy approximation to a theory of quantum gravity probably needs to be definable in spacetimes of nontrivial topology, even though such topologies aren't directly relevant at lower energies where quantum gravity effects are negligible. The Standard Model of Particle Physics satisfies this condition: its gauged symmetry group doesn't have any (known) 't Hooft anomalies on such spacetimes. This is stated below equation 3.5 on page 24 in arXiv:1808.00009, which says that the standard model defines a consistent quantum theory in any background, of any topology. That's probably not just a random coincidence.
Now, consider a spacetime $M$ with some not-necessarily-trivial topology. Consider a quantum model on $M$ that has some discrete group $G$ of global symmetries. Global means that the symmetry acts uniformly throughout spacetime. An 't Hooft anomaly is an obstruction to gauging the symmetry group $G$.
Gauging the symmetry group $G$ means, among other things, adding a corresponding gauge field to the model and summing over all possible configurations of this gauge field in the path integral, which in turn is supposed to define all of the model's quantum correlation functions. We have an 't Hooft anomaly if that sum turns out to be zero, because a model whose correlation functions are all zero is not a model at all.
For that to make sense, I need to explain what I mean by a "gauge field" for a discrete group $G$. This is another place where topology enters the picture. For any group $G$ (discrete or not), a gauge field configuration is defined to be a connection on a principle bundle, specifically a principle $G$-bundle over the spacetime manifold $M$. Roughly, a principle bundle is a topological space $E$ for which a quotient space $E/G$ can be defined, with $E/G=M$. Even more roughly, you can think of $E$ as a copy of $G$ for each point of $M$, varying smoothly from one point to the next. The smoothly-varying part is still required even when $G$ is a discrete group, but that doesn't mean the topology is trivial, because the bundle can be twisted: when you travel around a smooth closed path in $M$, you can end up a different element $g\in G$ than the one you started with, because a bundle is defined patchwise with possibly-nontrivial transition functions between the patches. For a discrete group $G$, the transition functions that define the principle bundle tell us everything there is to know about a connection on the bundle. It's purely a matter of topology in this case (a connection for discrete $G$ doesn't have any local curvature), and this is why I chose to consder a discrete group.
Now, the key question is whether or not we can define a quantum model by summing over all possible configurations of the gauge field. This is where things become really interesting. Topology enters here in yet another way, and this time it's specific to quantum physics, because the path-integral context is essential here. Actually, 't Hooft anomalies can be anticipated even before we calculate the sum, because we can treat the gauge field as a background field. This means that instead of summing over configurations of the gauge field, we treat the path integral as a function whose input is the gauge-field configuration $A$ and whose output is a complex number $Z[A]$. We can diagnose an 't Hooft anomaly by considering how this complex number varies as a function of the connection $A$.
I won't even try to explain how this works in detail, partly because this post is already long, but mainly because I'm a novice — I'm still working on building my own intuition about it. So I'll leave you with a few more keywords and one more reference. Possible 't Hooft anomalies are classified by bordism groups, typically denoted $\Omega(BG)$ with superscripts/subscripts to convey various other details. Here, $G$ is the symmetry group to be gauged, and $BG$ denotes the classifying space of $G$, defined to be the base space (spacetime) of a principle bundle for $G$ that is universal in the sense that any other $G$-bundle can be mapped into it. The literature about these ideas is vast, and it's absolutely drenched in both topology and QFT. For a place to start, I'll point you to these inspiring slides by one of the masters:
Witten's slides are not exactly introductory, but they are inspiring. They're a great example of the unique ways in which quantum physics involves topology.