PCl₅ is one of several reagents we have seen that are used for converting alcohols to alkyl halides:

Notice that in the case of chiral secondary alcohols, there is inversion of configuration, which indicates that substitution at the C–O carbon occurs via an SN2 mechanism.
The Mechanism of Reaction of Alcohols with PCl₅
The reaction starts with a nucleophilic attack of the alcohol oxygen on phosphorus, forming a chlorophosphonium intermediate (1).
After formation of this intermediate, chloride acts as a base and removes the proton from oxygen, generating a neutral phosphoryl species and HCl. This step converts the poor leaving group (–OH) into a very good leaving group attached to phosphorus (chlorophosphonate intermediate, ROPCl4). These intermediates are prone to ionization by losing a chloride ion, which is facilitated by the lone pair on the oxygen.
Finally, a chloride ion performs an SN2 attack on the carbon bearing oxygen, displacing the phosphorus-containing group as a leaving group and forming the alkyl chloride. This step is responsible for the observed inversion of configuration in chiral secondary alcohols.

Although acid-base reactions are generally faster, in the second part of the diagram, I have also shown the SN2 substitution that occurs by the earlier attack of the chloride ion on intermediate 1.
One question you may be wondering is how it is possible for the alcohol to attack her phosphorus. It may look a little strange since phosphorus already has five chlorine atoms connected to it. However, you need to remember that phosphorus is in the third period of the periodic table, has a larger atomic size, and can accommodate expanded valence through accessible d orbitals, allowing formation of additional bonds such as the P-O bond.
Tertiary Alcohols with PCl5
The conversion of alcohols to alkyl halides with phosphorus pentachloride (PCl₅) works best with primary and secondary alcohols. The reaction with tertiary alcohols is more complicated because SN2 substitution is not possible at a tertiary carbon, and competing elimination and rearrangement reactions may occur. Under carefully controlled, mild conditions, however, tertiary alcohols may still be converted to alkyl chlorides in good yields. Refer to the article Aust. J. Chem., 1976, 29, 133-43 for more details.
Other Methods for Converting Alcohols to Alkyl Halides
At the end, let’s mention that the conversion of alcohols to alkyl halides is a good method, especially for controlling the stereochemistry of the reaction. However, this is by far not the most common strategy you will see in your organic chemistry class. More often, you will be using SOCl2 and PBr3, together with mesylates and tosylates, to achieve similar outcomes.

Notice that using hydrohalic acids such as HCl and HBr carries the risk of carbocation rearrangements because they often promote the SN1 mechanism. That is why we use these alternative approaches, which also allow us to avoid the harsh acidic conditions.
Reference
Ingold, C. K., Structure and Mechanism in Organic Chemistry, 1st ed
Bridgewater, R. J., and Shoppee, C. W., J. Chem. Soc., 1953, 1709.
Shoppee, C. W., and Coll, J. C., J. Chem. Soc., C, 1970, 1124.

