Practically, how does an 'observer' collapse a wave function?
The other answers here, while technically correct, might not be presented at a level appropriate to your apparent background.
When the electron interacts with any other system in such a way that the other system's behavior depends on the electron's (e.g., it records one thing if the electron went left and another if it went right), then the electron no longer has a wave function of its own: the electron+"detector" system has a joint state. The two are entangled.
The electron doesn't have to "know" anything. The simple physical interaction results in a state vector which, by the laws of quantum mechanics, will preclude interference by any of the subsystems of this larger system. That said, the joint state can itself show a kind of "interference effect" (though not the kind you normally think of in the two-slit experiment).
If this entanglement is well-controlled (as in a lab), then (a) showing this "joint interference" might be practical, and (b) undoing the entanglement is also possible, thus restoring the electron's sole superposition. This is how we know that it hasn't "collapsed."
But if the entanglement is caused by stray photons, air molecules, etc., then any hope of controlling them becomes almost immediately dashed, and we can no longer exhibit interference in practice. From here on out, the system will appear to behave classically, with the different branches evolving independently. This fact is called decoherence. The superposition still hasn't "collapsed," but we no longer have the ability to show or exploit the superposition.
You may notice that this still leaves open a crucial question: when do the many branches become one? This is called the measurement problem, and physicists don't agree on the answer even today.
Wavefunction collapse is a feature of the Copenhagen interpretation, which is one interpretation of quantum mechanics. It isn't the only one. These days people don't really talk about interpretations of quantum mechanics. They talk more in terms of decoherence. One of the things that was always unsatisfactory about the CI was that it never defined what was meant by terms like "observer" and "measurement."
A more natural way to think about this is in terms of decoherence. When a quantum-mechanical system interacts with an environment, there is a tendency for its phase information to get scrambled. Decoherence is a theory that allows us to calculate this sort of thing, and, e.g., find the time-scale on which this phase information is lost. When the environment is a big thing with a lot of energy, the time scale for decoherence is very short. When people talk about observers and measurement, they're talking about objects so big and containing so much energy that this time scale is much shorter than any other time scale in the problem, and therefore it makes sense to treat it as an instantaneous collapse, as in CI.
Wave function collapse only happens in the head of the physicist.
What we are dealing with is entanglement of the electron and the detector wavefunctions. In the double slit problem we can write the electron wave function as $\psi_L + \psi_R$. The detector has two orthogonal states, $L$ and $R$. If there is no detector we have interference. If there is one and if it distinguishes the two possibilities with 100% certainty then the wave function must be $\psi_LL + \psi_RR$. This is an entangled state where interference is absent as $\langle\psi_LL | \psi_RR\rangle$
$= \langle\psi_L | \psi_R\rangle\langle L|R\rangle =0$.
No collapse occurs unless during the installation of the detector.