On erev Shabbat, the timing of the moch dachuk is slightly complicated by candle lighting, which represents an acceptance of Shabbat.
For Shabbat to count as the first of your clean days, you should ideally perform your hefsek taharah prior to accepting Shabbat. Thus, you perform your hefsek taharah and insert your moch dachuk just before lighting candles.
An alternative is to perform a hefsek taharah earlier in the day and then perform a bedikah just prior to sunset, without removing the cloth – the bedikah cloth remains inside and serves as a moch dachuk.
If neither of the above options is possible (e.g., it is too long for you to leave the moch in, or you forgot, or you are accepting Shabbat early), you may perform the hefsek taharah and insert the moch dachuk after lighting candles, just prior to sunset.
The moch dachuk is usually removed at nightfall, tzet hakochavim. For this purpose, the time of nightfall can range from as soon as 18 minutes after sunset to over an hour later, depending on local custom and geographical location.
Please note that insertion of the moch dachuk is an ideal, but its omission does not usually affect the validity of the hefsek taharah (see our article on the moch dachuk for more information). Additionally, if a woman has chronic problems with the moch dachuk, she may be given rabbinic permission to omit it.