While the dragon egg doesn't despawn once the Ender dragon spawns, it can still get destroyed by the dragon. So, it's best to quickly pick it up and store it at a safer location before getting involved in the main fight. Since you don't even need the egg to spawn the dragon, it is unnecessary to risk it.