How virtual photons give rise to electric and/or magnetic field? Say a neutron which have magnetic moment despite carrying no charge. Isn't both the electric field and magnetic field consist of virtual photons? So how can the same virtual photons give rise to 2 different properties? Since virtual photon is the excitation of a quantum field how come the same excitation of the quantum field can have different behavior like giving particle electric charge or spin?
 A: 
So how can the same virtual photons give rise to 2 different properties?

The photon is an elementary particle, and in the quantum field theoretical framework, an electromagnetic field exists in all (x,y,z,t) which has zero vacuum expectation value unless a photon exists there, the excitation of the field. What is the vacuum expectation value? It is the expectation value of the ground state of the photon wavefunction.
This wave function  is a solution of Maxwell's equations expressed with the potential,  where the differentials are quantum mechanical operators. It has   complex vaulues and hence phases . In synergy with other photon wave functions it builds up the classical electromagnetic field . Hence the photon wave function does have the possibility of building up electric and magnetic fields in symmetry.

Since virtual photon is the excitation of a quantum field how come the same excitation of the quantum field can have different behavior

Now on virtual photons : the term "virtual" means that a propagator is involved, in this case the photon propagator . By its definition a propagator is under an integral, even though it is identified with the quantum numbers of the photon, it is not a photon because under the integral it is off mass shell, its four vector does not have zero mass. It does have the other characteristics of the photon, including the phases and amplitudes that build up electric and magnetic fields , and thus can be used to define a static electric or magnetic field at the limit . Both fields can be built up, according to the boundary conditions of the problem, because the photon wave function carries information about both electric and magnetic fields.

like giving particle electric charge or spin?

Charge and spin are intrinsic particle properties, they are not built up. It is the fields that can be described by virtual particles
A: Try to start from the end and recapitulate, what was unknown in Maxwell's time. Electrons, neutrons, protons as well as their antiparticles have spin. This spin carries an angular momentum. This is known since Einstein and de Haas carried out their experiment with electrons. Furthermore it’s well known, that parallel to the rotational axis of this intrinsic spin all mentioned particles have a magnetic dipole moment. To orientate the magnetic moment of a particle, one has to switch on an external magnetic field. The Magnetic Resonance Spectroscopy MRI uses this phenomenon for the spin alignment of the whole atom.
Do we have another method to align the magnetic field of a particle? Yes, we have and it is called electromagnetic induction. The existance of intrinsic spin and related magnetic dipole moment is responsible for another phenomenon, called gyroscopic effect. When a particle moves and an external magnetic field aligns this particle, the particle gets deflected. The deflection takes place in the orthogonale direction to the plane between the magnetic field direction and the direction of the movement of the particle. Please never forget that the gyroscopic effect takes place only if there is a movement of the particle and if the orientation of the external field is not in axis with its movement.

Thinking about this, you may come to the conclusion that this defelction happens only one times; the orientation of the magnetic dipole moment takes place, the deflection happens and that was it. Here comes into the play the last phenomenon: Consider, that any deflection of a particle is an acceleration (a rotation or evolution of a body is an acceleration). And any acceleration led to the emission of photons. The best example for this phenomenon is a free-electron laser. 

The emission of a photon from a rotating body led to the gyroscopic effect too, this time in the other direction: The particle emits photons, gets disaligned, loses speed. And the whole process starts again. And this as long as the particle does not lose all its kinetic energy and came to rest in the centre of its spiral path.
Now we come nearer to your question. How the electric field is related to this effects? It isn't at all as long as we don't worry about how to speed up the particle to give it a movement. Electrons get moved by an electric potential difference, the resulting electric field moves the electrons from the source to the sink. Now, if you bend a wire to a spirale, you are the one who deflect the electron's path into a circle (I'm joking, the bended wire is responsible for the electrons trajectory). Try to use the above mentioned phenomenons. The emission of the photons during deflection - which is a acceleration, as was mentioned before - heats the coil by the emission of photons (mostly a negligible effect), the magnetic dipole moments get aligned and produce the magnetic field of the coil (the desired effect). Could you imagine now, that the electric field and the magnetic field interact only in the case of moving particles - which we produce by the help of an electric field - to induce magnetic fields.
Physics is talking about the exchange of virtual photons between electric fields OR between magnetic field. Why not between a magnetic field and an electric field, I explained to you above. If you make a search about what consists an electric or a magnetic field, you get nothing. Physics does not explain, what are the constituents of these fields. But it is postulated, that the exchange between fields happens by virtual photons. This is painful but accepted. More than that, despite the magnetic and the electric fields do not interact with each other, they have the same intermediating virtual photons.
Conclusion: Particles have unchangeable intrinsic properties: electric field (exclusion is the composed particle neutron), intrinsic spin and magnetic dipole moment (this is a field too). Particles under acceleration emit photons with their electric and magnetic field components. Virtual photons are the only explanation for the mechanism of the interaction between fields until today.
