The vaccines are effective if given before your first sexual exposure, and have not been exposed to the HPV types covered by the vaccine.
The vaccine will still benefit if you have been sexually active, as you may not have been exposed to the HPV sub types covered by the vaccines.