Both words are related to electricity, but 전기 means electricity itself, while 전자 means electronics.
When used like an adjective, they can describe the nature of the device's operation.
* 전기 = indicates electricity is the fundamental power source, as opposed to other means.
* 전자 = emphasizes that the device's functionality is primarily provided by complex circuitry involving electronic components rather than the electricity itself.
The distinction is a rough one emphasizing the primary method of the operation. Relatively simple devices based on driving a motor (전기차, 전기 면도기) or a lighting/heating element (전광판 (전기 광고판), 전기 장판) are usually called 전기 because electricity drives the primary function as opposed to other means like fossil fuel (전기차 vs 화석 연료 차 = fossil-fuel based automobiles). If the device provides an array of complex functions instead of simple things like moving, lighting, heating, etc, it can be called 전자 something (전자 수첩, 전자 사전, 전자 음악).
Sometimes, both terms can be used (전기 오르간 and 전자 오르간), but 전기 수첩 and 전자 면도기 are definitely not as natural as 전자 수첩 and 전기 면도기.