Aims. Upcoming large area sky surveys like Euclid and eROSITA, which are dedicated to studying the role of dark energy in the expansion history of the Universe and the three-dimensional mass distribution of matter, crucially depend on accurate photometric redshifts. The identification of variable sources, such as active galactic nuclei (AGNs), and the achievable redshift accuracy for varying objects are important in view of the science goals of the Euclid and eROSITA missions. Methods. We probe AGN optical variability for a large sample of X-ray-selected AGNs in the XMM-COSMOS field, using the multiepoch light curves provided by the Pan-STARRS1 (PS1) 3π and Medium Deep Field surveys. To quantify variability we employed a simple statistic to estimate the probability of variability and the normalized excess variance to measure the variability amplitude. Utilizing these two variability parameters, we defined a sample of varying AGNs for every PS1 band. We investigated the influence of variability on the calculation of photometric redshifts by applying three different input photometry sets for our fitting procedure. For each of the five PS1 bands g P1 , r P1 , i P1 , z P1 , and y P1 , we chose either the epochs minimizing the interval in observing time, the median magnitude values, or randomly drawn light curve points to compute the redshift. In addition, we derived photometric redshifts using PS1 photometry extended by GALEX/IRAC bands. Results. We find that the photometry produced by the 3π survey is sufficient to reliably detect variable sources provided that the fractional variability amplitude is at least ∼3%. Considering the photometric redshifts of variable AGNs, we observe that minimizing the time spacing of the chosen points yields superior photometric redshifts in terms of the percentage of outliers (33%) and accuracy (0.07), outperforming the other two approaches. Drawing random points from the light curve gives rise to typically 57% of outliers and an accuracy of ∼0.4. Adding GALEX/IRAC bands for the redshift determination weakens the influence of variability. Although the redshift quality generally improves when adding these bands, we still obtain not less than 26% of outliers and an accuracy of 0.05 at best, therefore variable sources should receive a flag stating that their photometric redshifts may be low quality.