It is not illegal to use a unique mark on goods in commerce even though that mark is not yet registered with the USPTO. In fact, trademark rights arise from use, not registration. However, the wisest route is to do a trademark search before adopting, and using, a new mark in commerce. That would ensure that you are not infringing on a trademark that is already in use.
Q: "Is it illegal to have this already in commerce as far as the trademark office is concerned?"
R: Not as long it's your company that's selling the product branded with the mark you're just now getting around to register. As noted by my colleague, registration is voluntary. Registration is a good idea because it confers significant benefits, but it's not required. As also note, you should have a trademark attorney "clear the rights" to the mark before you file your registration application. Once you file, anyone with a confusingly similar mark who moniters such filings will know about your use -- which puts you at a disadvantage. You should know who else is using a similar mark before you apply to register. Good luck.
The above response is general information ONLY and is not legal advice, does not form an attorney-client relationship, and should NOT be relied upon to take or refrain from taking any action. I am not your attorney. You should seek the advice of competent counsel before taking any action related to your inquiry.
Not sure I completely get your question. Is it legal to trademark a name that's already being used by you in commerce? Sure. In fact, that's one of the bases for trademarking a name, that you've been using it in commerce. Is it legal to allow a corporation to use a trademark that was in use before the corporation existed? Sure, that's a common practice.
The contents of this answer should be considered friendly advice, not legal advice (I'm a pretty friendly guy), and the answer should not be construed to constitute an attorney-client relationship. Also, if you liked this answer as much as my big ego thinks you did, be sure to click the thumbs-up button!
Your additional information in comments was: "What I actually mean is the product was being sold without any legal entity. Now I am partners registering the trademark. Is it penalty to register a trademark when product is already being sold but has no legal entity?"
First, you did have a legal entity. You as an individual are a legal entity, albeit a small entity or micro-entity. Second, the partnership can assume your use-based rights by transfer from you. If the partnership files a declaration of first use as of your date of first use, the USPTO will just accept it, as the USPTO has no basis to challenge it. You should have an IP attorney review this and get your documentation in order, however, as some counterparty might challenge your partnership declaration of use if you don't document it.
I am not your lawyer and you are not my client. Free advice here is without recourse and any reliance thereupon is at your sole risk. This is done without compensation as a free public service. I am licensed in IL, MO, TX and I am a Reg. Pat. Atty. so advice in any other jurisdiction is strictly general advice and should be confirmed with an attorney licensed in that jurisdiction.
It does not matter to the USPTO whether the trademark was in use under a proper entity or not.
Further, whenever you endeavor into investing in a trademark it is very important that you conduct the proper clearance due diligence upfront and before you submit an application to the USPTO. In the US, this means searching under both federal (USPTO) as well as common law because trademark rights stem from use in this country NOT registration. This means that acquiring a federal registration does not necessarily mean that you are not infringing on another's intellectual property. See the link below for a detailed explanation of the due diligence process.
I suggest that you consult with a lawyer in private and discuss your objectives in more detail. You can start by calling around to several for a free phone consultation, get some insights then pick the best fit to work with.
DISCLAIMER: this is not intended to be specific legal advice and should not be relied upon as such. No attorney-client relationship is formed with the law firm of Natoli-Lapin, LLC on the basis of this posting.