Wouldn't it be nice if your machine could tell you when it needed oil like the Tin Man in the 1939 Wizard of Oz motion picture? New computerized machines can communicate many things, but I don't know of one that keeps track of how many hours you've sewn and whether or not it is time for a tune-up. (Designers are you listening? This would be an excellent feature!)
Keeping your sewing machine clean is the key to keeping it working. Many experts suggest cleaning it after each project. Preventitive Sewing Machine Maintenance, an online 2008 article by Sally Hickerson for Threads Magazine, puts it simply: "just a few minutes daily, weekly, or monthly— depending on how much you're sewing— you can help keep your machine running smoothly" The one part of the cleaning regime that seems to be most allusive is how often and when to oil a sewing machine. She gives this tip for oiling the bobbin: "Use a soft piece of muslin with a dot of sewing machine oil to clean the race hook. If the hook is removable, place a drop of oil on it before returning it to the machine" with a photograph, but again, the question is when and how often.
Oiling your machine too often or in the wrong spot may harm it. A quick google search and you will find a range of advice from 'oil it every eight hours of sewing' to 'more often for quilting' to 'oil every three to five bobbins'. Much of this depends on the age of the machine. New sewing machines are oiled at the factory and depending on where you bought it, your salesperson will likely have instructed you to oil the race hook as described above. If you bought a used machine from a private party and don't know when it was last serviced I would ere on the it probably needs to be oiled side. Oiling may also depend on the brand of machine. Keep in mind I am talking about lockstitch machines: sergers and specialty machines are a whole other ball of wax. If you have an old Bernina, for example, it may not be as easy to get to the race hook as it is on an old Kenmore and you may need to be a bit of a sleuth to figure out how. (Those of you with old Bernina 830s or 930s: there is a good photo with instructions here)
The best advice I can give you is to check the instruction manual if you have it. If it is an older machine you may be able to download a pdf version on the internet. I have links to several places who sell these on my machine info page. Page 29 on my manual for my 1970s Montgomery Ward 1942B (mechanical) machine suggests you oil the machine every week if you use your machine every day. Another manual I have describes in detail where to oil the machine, but not when or how often. If you don not find clear instructions call a service person and ask. Make sure to describe the use of your machine in detail (I have sewn on this for blank hours since it was last oiled - or this machine hasn't been used since 1954...) so they can help you make an informed decision for what to do.
Most sewing machine oil is made in China and India and is a petroleum-based light weigh white oil (spray silicone versions are lubricants and will not work to oil the machine). There is a website called Sewing Machine Oil (of course there is!) where you can find links to every kind of machine oil for home sewing and industrial sewing machines out there and with suggestions for which to use with what and why. For those of you who are concerned, yes, it is toxic and yes, there are some ideas for homemade non-toxic versions out there. Here is one recipe I found on eHow that used jojoba oil, silicone oil and ester oil. I've also read it is okay to use a bike chain oil: Tri-Flow sells a sewing machine specific oil. What you should never use is olive oil or cooking oil (it will become rancid), motor oil (too heavy) or a 3-in-1 oil: it contains paraffin and will harden in your machine.
I found some good advice for what kind of oil to use on antique machines at Treadle On which suggests using WD-40 to clean the moving parts of the machine (don't put it in the oil holes - it is a water dispersant and a lubricant, not an oil) and then use sewing machine oil (in the oil holes) to get it ready to sew. They also point out if you spill or drip oil somewhere you don't want it to be, use a product like Simple Green or to wipe it off. I can vouch that this works well - I recently had a tube of oil spill in the arm compartment of my machine and after freaking out I called my repair shop and they suggested this as well.
Whew, I never knew I had that much to write about oil! Let me know if you have some other information not covered here. I am learning as I do this, so please don't be afraid to tell me I am wrong.