Yes, you can retake an AP Exam in any subsequent year that the exam is offered. There is no penalty or restriction from the College Board for retaking an exam. If you were not satisfied with your score the first time, you have the opportunity to study and try again. This can be a good option if you need a higher score for college credit or if you feel you can significantly improve your result.
However, it's important to understand how score reporting works with retakes. All of your scores for a particular subject are retained on your College Board record. When you send your scores to a college, they will receive all the scores you have ever earned for that exam unless you take action to withhold or cancel a score. For example, if you got a 3 on AP U.S. History in 11th grade and retook it in 12th grade and got a 5, the college would see both scores. In most cases, colleges will consider your highest score, but it's something to be aware of. Before deciding to retake an exam, consider the time and effort required and weigh it against the potential benefit of a higher score.