An electronic device comprising: a housing (511, 512, 513, 514); a touchscreen display exposed through a portion of the housing; at least one wireless communication circuitry; an electromagnetic, EM, signal sensing circuitry configured to sense an EM signal; a processor operatively connected with the touchscreen display, the wireless communication circuitry, and the EM sensing circuitry; and a memory configured to store a reference EM profile including information associated with an external electronic device and operatively connected with the processor, wherein the memory stores instructions that, when executed, cause the processor to: obtain an EM signal of the external electronic device through the EM sensing circuitry; identify the external electronic device corresponding to the obtained EM signal, based on the reference EM profile; determine whether the identified external electronic device is a device to input or output an audio signal; when the identified external electronic device is not the device to input or output the audio signal and connected with the electronic device, display a screen for controlling the identified external electronic device; and when the identified external electronic device is the device to input or output the audio signal and connected with the electronic device, change a path of an audio signal, which is output by the electronic device, such that the audio signal is output through the external electronic device, wherein the EM signal is due to electromagnetic interference caused by internal electric components of the external electronic device. a housing (511, 512, 513, 514); a touchscreen display exposed through a portion of the housing; at least one wireless communication circuitry; an electromagnetic, EM, signal sensing circuitry configured to sense an EM signal; a processor operatively connected with the touchscreen display, the wireless communication circuitry, and the EM sensing circuitry; and a memory configured to store a reference EM profile including information associated with an external electronic device and operatively connected with the processor, wherein the memory stores instructions that, when executed, cause the processor to: obtain an EM signal of the external electronic device through the EM sensing circuitry; identify the external electronic device corresponding to the obtained EM signal, based on the reference EM profile; determine whether the identified external electronic device is a device to input or output an audio signal; when the identified external electronic device is not the device to input or output the audio signal and connected with the electronic device, display a screen for controlling the identified external electronic device; and when the identified external electronic device is the device to input or output the audio signal and connected with the electronic device, change a path of an audio signal, which is output by the electronic device, such that the audio signal is output through the external electronic device, obtain an EM signal of the external electronic device through the EM sensing circuitry; identify the external electronic device corresponding to the obtained EM signal, based on the reference EM profile; determine whether the identified external electronic device is a device to input or output an audio signal; when the identified external electronic device is not the device to input or output the audio signal and connected with the electronic device, display a screen for controlling the identified external electronic device; and when the identified external electronic device is the device to input or output the audio signal and connected with the electronic device, change a path of an audio signal, which is output by the electronic device, such that the audio signal is output through the external electronic device, wherein the EM signal is due to electromagnetic interference caused by internal electric components of the external electronic device.