Its best probably to restore the tooth first then whiten your teeth to avoid sensitivity / problems . Following whitening depending on where the cavity is it may have to be re filled to match the new whiten shade of your teeth.