I came to the U.S. as a foreign student, and fell in love. After graduation, I stayed, because I got pregnant and my boyfriend planned to get married. But he changed his mind. Now I have a son, who was born in the U.S. last year. I have heard that the mother of a U.S. citizen is eligible for a green card. How soon can I apply?
You have a long wait ahead. For a U.S. citizen child to petition for a parent, the child must be at least 21 years of age. If you wait in the U.S. all that time, and have no lawful immigration status (which it sounds like you don't), you risk being caught by immigration authorities, placed in removal proceedings, and eventually deported from the United States.
Deportation always comes with an order that the person not return for several years (the exact number depending on the legal grounds for your removal). See How Long After Deportation Must I Wait Before Returning to the U.S.?
You might be able to find a legal way to spend some time in the U.S. in the meantime, such as on a temporary, nonimmigrant work visa. But given that it sounds like your student visa has run out, you will need to return to your country to apply for another visa. People who have fallen out of status in the U.S. cannot, in most cases, change or adjust their status (that is, apply for a new or different right to be in the U.S.) without first leaving the country. Your application would have to be made through a U.S. consulate in your home country.
There is an exception to the rule prohibiting people from changing or adjusting status if they're not already in the U.S. in legal status. It applies to immediate relatives of U.S. citizens who entered the U.S. legally (with inspection, probably with a visa) and will be applying for a green card through that U.S. citizen. They are allowed to “adjust status” to permanent resident without leaving the United States. That could be you after your child turns 21—but again, if you just stay in the U.S., you are facing a long, not to mention illegal, wait in the U.S. to get to that point.
People who leave the U.S. or get deported after living here illegally have another problem to worry about. Those who've spent more than 180 days in the U.S. in "unlawful presence" and then leave voluntarily will not be allowed to return for three years. Those who have more than one year of unlawful presence then leave or get deported will not be allowed to return for ten years. "Unlawful presence" is a special concept in immigration law—it's not exactly the same thing as being out of status, like you are. (For details, see Consequences of Unlawful Presence in the U.S.—Three– and Ten-Year Time Bars.)
Let's imagine for a minute that you do stay in the U.S. until your child turns 21 without getting caught, or that you leave and apply for a visa to return lawfully, or that you and your child leave together. There's another potential complication you should know about.
In order to petition for you to get a U.S. green card, your child will need to also qualify as your financial sponsor. To do that, he needs to be both living in the U.S. and earning enough to support the two of you and any other dependents at 125% of the poverty level, as shown in the U.S. Federal Poverty Guidelines. For more on this issue, see articles about The U.S. Sponsor's Financial Responsibilities.
As you can see, U.S. immigration matters are highly complicated. In fact, if you're reading this and your situation is not similar to the questioner's—for example, you entered the U.S. without inspection—you should not attempt to analyze your situation based on the guidance provided here. See an experienced immigration attorney for a full analysis.