The fluid is secreted by Cowper's glands during foreplay or at an early stage during sex, long before the man reaches orgasm and semen is ejaculated.
A problem for couples who seek to avoid pregnancy, however, is that the pre-ejaculate may include some sperm. This is one additional reason why withdrawal (coitus interruptus) is not considered to be a reliable method of birth control.