How to ask a teacher for an extension?
Most universities have an office dedicated to helping students deal with disabilities of various kinds. Perhaps you should visit them. They can probably help with stress reduction. In extreme cases a doctor's help might be needed. 

But, you might also consider asking your professor for an alternate way to take the exam than online. Perhaps taking it on paper would be helpful. Perhaps having someone else in the room with you would be helpful. But think about more options than just additional time. There is something going on in your life that suggests that time, alone, isn't the issue. 

Even an oral exam is better for some people, though not everyone. But it requires a certain amount of empathy from the professor that not all will exhibit. 

But if you need to ask, do so in person if at all possible. It is more likely to be successful and the professor might be able to suggest alternatives that won't come up in an email exchange.