The best time to book flights to Madrid depends on several factors such as the season, holidays, and major events. Generally, it's recommended to book flights at least two months in advance to get the best deals. However, if you're looking to travel during peak season or a major event, it's best to book even earlier to secure your preferred dates and avoid higher prices.