You must take the loss in the year that the securities became worthless. If you discover that your securities became worthless in a prior year, you are allowed to go back up to seven years to amend your tax return to obtain a refund. Normally, you may only go back three years. Please note that when a company declares bankruptcy it does not necessarily mean that the securities are worthless.
Report your worthless securities transactions on Form 8949 with the correct box checked for these transactions. See Form 8949 and its instructions.