When it's processed according to U.S. Pharmacopeia standards in an extended release formula, IIRC.
I'm not going to dispute U.S. Pharmacopeia standards, but I believe that in the case of megadoses of niacin, it is the dose level that makes it a drug. My daily b-50 and vitamin C pills are time release, and over the counter.