The best way to get rid of the paint is to tape the top and inside flange of the rails before you spray-paint the rails. You would simply cut some masking tape into small strips and stick the tape to the rails. This, however, can be quite time consuming.
Another trick is to wipe the top and flanges of the rails with heavy oil on the principle that the oil won't allow the paint to stick to the rail head and flanges. I've had mixed success with that method but it's better than not applying any oil at all.
The best trick, combined with the oil trick, is to wipe the top of the rails and the flanges before the paint has a chance to dry. This requires a lot of Kleenex/ rags but is well worth the time and effort. Simply wrap the Kleenex/ rag around your index finger and wipe. You will get about 4" down the rail when you will have to move the Kleenex/ rag on your index finger. This won't, however, get rid of all the paint so you will have to do some extra work after the paint dries.
Regardless of whatever method you use, you will usually have to use some "elbow grease" to get rid of the paint. I use a 1/8"x 1/8" steel bar about 4"x 6" long with a square notch filed into the bar about ¼" from the end. This allows me to hook the bar over the track. I can then scrape off more of the paint residue off the top of the rail and off the inside flange. If you use a file, you can end up scarring or filing the top of the rail. However, sometimes the file can be used to get rid of a heavy coat of paint.
Ultimately, you will end up using the final product - paint stripper. But not the kind you use to strip doors. One of the model paint manufacturers makes a paint stripper that can be used on plastics. This is a milder version of the real McCoy and doesn't attack all of the paint. It's a simple matter of getting a bit on the end of a Kleenex or rag that you wrap around your index finger and patiently rub the top of the rail and the inside flange. It does, however, produce beautiful results.
Once the paint has been removed and the dried blobs of paint picked off the tracks (yes you will end up with dried blobs of paint), polish the top and inside flange of the rail with a Bright Boy or sand sponge. I don't recommend using sandpaper as this will scar the top of the rail.
For an idea of the process, take a look at this page on my website. Unfortunately, I don't have a photo on the website of the final results. But it is quite stunning, if I do say so.
http://www.railwaybob.com/Modules/Roadbed-Tracklaying/RoadbedTrackLaying01.html
When spray painting around turnouts, make sure you stuff some Kleenex in the open point rail and make sure it's well in place. This will save you lots of headaches.
Remember, however, that in all of this process, patience IS a virtue.
Bob M.