So, there are some specific rules according to how the compound noun is created.
This source, from the dictionary of one of the most important Italian newspapers, lists them. In the following, adj stays for "adjective", v for verb, adv for adverb, prep for preposition and sub for "substantive".
- Nouns composed as adj + sub make the plural pluralizing only the second;
- Nouns composed as adj + adj make the plural pluralizing only the second;
- Nouns composed as sub + adj make the plural pluralizing both;
- Nouns composed as sub + sub of the same gender make the plural pluralizing only the second;
- Nouns composed as sub + sub of different gender make the plural pluralizing only the first;
- Nouns composed as v + plural sub make the plural without any change;
- Nouns composed as v + singular masculine sub make the plural pluralizing only the second;
- Nouns composed as v + singular feminine sub make the plural without any change;
- Nouns composed as v + v make the plural without any change;
- Nouns composed as adv or prep + sub make the plural pluralizing the noun if the composite has the same gender of the component and without any change in the opposite case.
Please note that the composite noun may change gender with respect to the component nouns/noun.
Moreover, there are exceptions to the rules. The cited source reports plenty of examples of rules and exceptions.
I report some examples here, in the same order used in the list above. The first column is the singular, the second is the plural.
- bassorilievo --- bassorilievi
- bassofondo --- bassifondi
- terracotta --- terrecotte
- pescecane --- pescecani
- pescespada --- pescispada
- portapenne --- portapenne
- copricapo --- copricapi
- posacenere --- posacenere
- saliscendi --- saliscendi
- A. sottufficiale --- sottufficiali / B. sottoscala --- sottoscala
Remember, there are unfortunately plenty of exceptions. We natives apply them without even knowing them, as in other cases. Do not be afraid of making mistakes, you can be sure only if you meet the word as many times as you need to learn it along with its plural.