Subroutines can be found in Colonial Derelict stations.
You need an access key (usually drop from elite enemies once you kill them).
They are bright blue beams of light with a floating blue cube. They are found in locked rooms with "Special Equipment Containers".
Rather than waste a key, fly round the exterior of the room and look through the gaps. It'll be pretty obvious if there's a subroutine in there.
Fly close to one and you'll start a progress bar to download it.