I need help with a simple IR circuit to control electromagnets
Here's a diagram of a basic circuit that came to mind while reading your question. Ideally, this may fulfil your need, but otherwise it at least gives us somewhere to start from.


In this circuit, D1 is your IR LED & "sensor" is your detector.
The 10Kohm resistor is required by your detector.
Q1 is a [IRLML6344TRPBF][2] MOSFET ($0.36 @ digikey.com). It "turns on" completely at ~4.5V signal level (so your 5V detector circuit can run it), and can handle ~10x your rated load from your solenoids & 2.5x the voltage; so no relay needed.
The diode parallel to Q1 "freewheels" to keep coil inductance from causing overvoltage & destruction to Q1 (Q1 has an internal diode to do this to, but better safe...).