how come does the current flow when Q2 is on, from the ground to Vsw?
Because of what you said earlier: "the drain and source are determined by the pin with the higher voltage".
In this circuit, you first turn on Q1, establishing a left-to-right current through L. Now, when you switch off Q1 and switch Q2 on, the voltage on the left end of the inductor will drop to below ground, so the upper end of the FET acts as the source and the lower end acts as the drain, and current continues to flow left to right.
The key thing going on is actually in the inductor, not the FET. Since the current through the inductor can't change instantaneously, and the right end of the inductor is at a (roughly) fixed voltage because of the output capacitor (whose voltage can only change slowly), the right end of the inductor must drop to a below-ground voltage to keep the current flowing. And the inductor uses its stored energy to "carry the current up-hill" from a low voltage to a high voltage, until either the next charging cycle starts (for continuous-current mode CCM), or the current drops to zero and Q2 is shut off (for discontinuous current mode DCM).
Is it flowing from the source to the drain?
It depends if you want to define the "source" and "drain" according to their nominal designations or according to how they function in the circuit at each instant. Really the FET doesn't care what you call its terminals --- if the gate is sufficiently positively biased, current will flow through the channel from whichever terminal is at a higher potential to the other terminal.
And why not use a pmos instead, so that the current will flow from the source (the ground) to the drain (Vsw)?
First, current already does flow from ground to Vsw in the circuit as it is.
With a PMOS, you'd have to drive the gate below ground (by at least a volt or two) to turn it "on" and this would be inconvenient.
Also, PMOS devices are typically less efficient than NMOS devices of the same size built in the same technology, because the hole mobility is lower than the electron mobility.