It is theoretically possible to get HIV from giving head but the likelihood of this occurring is very low. No one knows exactly how risky it is, partly because most men who do it will also have other forms of sex as well and it is impossible to know which sexual act is responsible for the transmission of HIV.
The reason that oral sex is so much safer than anal sex is that the throat is not as vulnerable to infection as the rectum is. Saliva has properties that can disable some infections, including HIV, and so there needs to be quite a lot of HIV present for infection to take place. Also, the mouth and throat are not as efficient at absorbing liquids into the bloodstream as the lining of the rectum is. Even if you swallow cum, any HIV that may be there will usually be killed by the strong acids in your stomach.