An electric field is produced by several factors, but the most direct answer to the question is:
B. when an object has an electric charge.
Electric fields originate from charged objects, whether they are stationary or in motion. However, options A and D also involve the movement of charges and can create electric fields, especially in dynamic situations (like in a circuit or a current). That said, the most fundamental answer is option B.