Magnetic fields permeate the entire universe, extending from the smallest to the largest observable length scales. A popular explanation for the origin of the magnetic fields observed in galaxies, clusters of galaxies, and the intergalactic medium is that seed fields generated due to quantum fluctuations in the primordial universe are amplified later by astrophysical processes. According to the standard paradigm of magnetogenesis, the seed magnetic fields on cosmological scales are generated during inflation by breaking the conformal invariance of the standard electromagnetic action. This is usually achieved through a non-conformal coupling of the electromagnetic field to the scalar field that drives inflation. Also, a parity-violating term is often added to the action to generate helical magnetic fields. I will begin the talk with a brief introduction to the essential idea of inflation. Thereafter, I will first discuss the effects of deviations from slow-roll inflation on the spectra of non-helical and helical electromagnetic fields over large and small scales in single-field models of inflation. To circumvent the challenges that arise in single-field models, in the second part of the talk, I will discuss the generation of magnetic fields in two-field models of inflation. I will also discuss the imprints of the primordial magnetic fields generated in certain two-field models on the anisotropies in the cosmic microwave background. Lastly, I will cover the ongoing projects and outline the future plans that I intend to work on.