There is no grace period after status ends. Once your status ends you are supposed to depart the US. You indicate your application was rejected. Was it submitted while you were still in status? and did you have continue to have status?
As long as you have not been out of status for more than six months you will not have a bar on returning to the US based solely on being out of status. Assuming you have no other issues you may apply for H-1B and return to the US if granted.
Since there several facts that are missing from you question, you should consult with an immigration attorney as soon as possible to protect your interests.
PROFESSOR OF IMMIGRATION LAW for over 10 years -- This blog posting is offered for informational purposes only. It does not constitute an attorney-client relationship. Also, keep in mind that this is an INTERNET BLOG. You should not rely on anything you read here to make decisions which impact on your life. Meet with an attorney, via Skype, or in person, to obtain competent personal and professional guidance.