Unlike in The Wind Waker, you cannot control the direction of the wind in Sea of Thieves. So if you need to travel into a headwind, you just have to deal with the unfavorable wind direction. What is the fastest way to sail into a headwind?
So if it is very slightly off to one side you are better off trying to turn the sails so it has the wind a little bit. if you have to sail directly into it then you typically turn the sails to be directly forward and have them dropped all of the way. The larger the ship you use the slower you are against wind (Galleon slowest and sloop fastest) which also means that the Galleon is faster than a sloop when they both have the wind.
Another suggestion is if your destination is far away to the northwest for example, it may be faster to sail straight north if it gives you some wind and do this until the wind changes or until you would have to sail straight west. Usually it is better to take a route that is a longer distance when you have the wind because it can be so slow. Again this is what I would do in a Galleon but in a sloop I would probably sail straight into the wind.
The more you play the more you will get a feel for everything and speeds with the different ships. Another suggestion to learn general things about the game and tips is watch some popular streamers on twitch or their youtube. I watch Pace22 a lot and he significantly improved my playing