The simple answer is: you file a tax return (form 1040 plus any required additional IRS forms). There is a three year limit for filing for a refund (there is no time limit if you owe money). Example: to claim a 2021 refund, you must file by April 15, 2025 (3 years from April 15 2022, the deadline for filing a 2021 return). If you filed for an extension, the deadline is Oct. 15, 2025. It is too late to claim a refund for 2020 or earlier years (unless you filed for a 2020 extension).
But, as others have said, it depends on the details of your situation.