You allocate spending to train spies from your Domestic Stats. Espionage spending is at the bottom, below your production sliders.
There's also a separate tab for espionage, where you can place agents on civilizations (in 2.0), and it shows you the time until your next spy is trained.
You don't need any tech researched to start training spies.
Building a Counter Espionage Center on a planet makes that planet (and that planet alone) immune to spies.