There are limits to this, some of which are set out in South Dakota v. Dole, 483 U.S. 203 (1987). These limits (quoting wikipedia) are:
* The spending must promote "the general welfare."
* The condition must be unambiguous.
* The condition should relate "to the federal interest in particular national projects or programs."
* The condition imposed on the states must not, in itself, be unconstitutional.
* The condition must not be coercive.
Especially the last condition is relevant. It means the withdrawal of funding cannot be so harsh as to be clearly funding. I believe the actual wording used is that the threat of withdrawal cannot be a 'gun to the head' of the states.