Śrīmad-Bhāgavatam · Text 2.3.8
Who is speaking and story frame
धर्मार्थ उत्तमश्लोकं तन्तु: तन्वन् पितृन् यजेत् ।
रक्षाकाम: पुण्यजनानोजस्कामो मरुद्गणान् ॥ ८ ॥
dharmārtha uttama-ślokaṁ
tantuḥ tanvan pitṝn yajet
rakṣā-kāmaḥ puṇya-janān
ojas-kāmo marud-gaṇān
One should worship Lord Viṣṇu or His devotee for spiritual advancement in knowledge, and for protection of heredity and advancement of a dynasty one should worship the various demigods.
Read Śrīla Prabhupāda's purport on Vedabase.io