Nolatom pretty much sums it up
Barring no obstacles (land, shallows, traffic, etc.) as you head up to a mark, if you're getting headed I say more than two times, then switch tacks until you start getting headed the other way. If the wind is slowly shifting direction, stay on the tack that is getting the lift (relative to the mark) as long as you can. Once on the header tack, only stay on it as long as you need to cover enough distance so that when tack back to the favored bearing, you can ride it for a while. This minimizes distance traveled and gives to the best VMG to your mark.
If you liked my advice/response, give me some rep points. If you didn't......well what do you expect, it was free.