This is a question that people with various qualifications have been trying to answer for centuries.
While the question had reportedly occurred to Julian Jean Cesar Legallois (a French psychologist) in 1812, the first confirmed experiment regarding decapitation took place in 1857, when Charles Edouard Brown-Séquard tried to keep the head of a decapitated dog alive with blood transfusion. Apparently, he managed to prolong the animal’s life for a couple of minutes, before it died amid excruciating pain.
A couple decades later Jean-Baptiste Vincent Laborde tried to revive a death row inmate with fresh blood. His experiment ended in failure, although he attributed this to the apparently “outrageous” amount of time that passed between the death of the inmate and Laborde getting access to the body. He requested a second test subject, whom he claimed to have kept alive for a full minute; although the inmate never regained consciousness after the execution.
Around the same time, Paul Loye built a guillotine in his laboratory in order to study decapitated dogs. He concluded that while the mouth of a decapitated animal may move for a couple minutes, victims lose consciousness at the moment of decapitation.
Modern science’s take
According to the New Scientist’s article regarding non-natural causes of death, death after decapitation is brought about extremely fast; victims usually lose consciousness after 2-3 seconds. There are other publications that point out that this time may actually be 15 seconds.
A 2011 study investigating the decapitation of rats found that death usually occurs in 4 to 15 seconds from the point of decapitation. While this falls in line with previous findings, the researchers also identified an unexplained spark in brain activity about a minute after decapitation.
Keeping decapitated heads alive
With all that being said, there have been a number of experiments that managed to substantially prolong the suffering life of decapitated subjects. Soviet scientists have managed to keep decapitated dog heads alive for about 3 hours. Furthermore, the head was even shown to be reactive towards external stimuli.