It depends. If the stock sale was inside of a retirement account then it would be taxed when you receive distributions as retirement.
If it was from your financial holdings outside of a retirement account, then you must include the stock sale profit in your income regardless of your age.