Well, every female birth has an equal chance of being a male birth, so in principle any of the female Habsburgs could have been born male, but that's no guarantee of having a male line that descends to the present day.
But the easiest is probably to have Baltasar Carlos (the son of Philip IV by his first wife) survive. Not only does his Bourbon mother mean that he's somewhat less ludicrously inbred than Charles II, he will avoid the War of Spanish Succession and the end of Habsburg rule in Spain. In this scenario, it's entirely possible that a Habsburg monarch could still be ruling Spain (at least as much as Juan Carlos does).