How long did it take for Earth's magnetic field to first appear?
The age of the Earth's magnetic field could be as old as the existence of the physical conditions capable of generating a magnetic field. Because we believe the geomagnetic field originates from the liquid outer core, your question could be restated as: When did the Earth form a liquid core?

How the Earth's core formed is still not well understood and the area of research is referred to as planetary differentiation.