There is a good amount of case law addressing this question going back two centuries. Legally, as soon as you are subject to "excessive force," you are allowed to defend yourself as you would against any assault, even if that force is being used in the course of an otherwise lawful arrest.
Furthermore, in some states you are still allowed to resist unlawful arrest.
Unfortunately, the matter is no longer as clear as it used to be. (There is a lot of material on this subject; just search for resisting unlawful arrest
.) For example, police reflexively invoke a virtual safe harbor by shouting, "Stop resisting!" while battering arrest subjects. Video evidence has uncovered a plethora of examples in which this was done to subjects who were not only not resisting, but even later determined to have been incapable of resisting.
If you intend to defend yourself against police, even when justified by law, you need to realize that the system is stacked against you. Police carry the means of escalating to lethal force. So, for example, if you are being beaten but you are potentially able to physically overpower and restrain an officer, you will likely then be met with baton blows or tasers. Since a baton is a deadly weapon, you would be (in theory) justified in shooting an officer attacking you with one. But as soon as any officer shouts "gun!" you will be shot, and most likely killed. Police seem to be given the benefit of the doubt by prosecutors and grand juries when they claim, "I feared for my life." You (even if you survive) will likely have any such claim subject to a full criminal trial.
So even though you can legally defend yourself against excessive police force, these days you will almost certainly be unable to in practice.