It is safe to take valtrex prior to surgery but you should not have an active infection at the time of your surgical porcedure especially if this is in the oral area.
Valtrex is safe to take before and is very beneficial for those who tend to break out in cold sores due to stress. As a rule let your surgeon know about any medication you are taking before a procedure.